funnl
The main purpose of this package is to have a utility which can pipe data easily and flexibly.
To build
Clone the repo, then run npm install
or yarn init
Code examples
// Importconst funnl = ; /* OR w/ ES6 */ // Two ways: // 1.// First is to use callback functionsconst res = ` World!` { return message } ;console; // { message: "Hello World!" }... // 2.// Second, define, and then pass functions// Notice, when a function has more than one argument,// we pass an array with the first element being the function.// The result of the first element in the pipe is then passed// as the first arg of the next function call, then// the rest of the args get passed along, so the eventual// function call looks like:// add(2, 8)// given the example below.const adda b => a + b;const res = add 8 ;console // 10
async/await
funnl also supports async/await functionality.
To calculate async values, you can declare async/await in the chain, or inside a function.
Example of async/await in a function:
async { await ; // Pause for 200ms to mock network call return users: value ; } data; // There are 10 users online! // OR async { await ; // Pause for 200ms to mock network call return users: value ; } async { const users = await data; console }; // There are 100 users online! // OR const add = args;const calc = async await add 1 2 3 4 res * 2 data: res // { data: 40 }