weldy
A sort of pipe operator (|>) implementation for Node.js based on co.
weldy takes a value and an array with the following structure [ [fn_1, ...args], [fn_2, ...args], ... ,[fn_n, ...args] ]
, processes each element invoking fn
, using as first argument the output of the previous one (if it returns any value) and the ...args
. It returns a promise.
The first argument of the first function can be passed as the first weldy
param.
Examples
Simple arithmetical operations:
CRUD operations on mongodb:
{ return db} { return dbnext} { console return db} { console}
Usage with node-fetch:
API
weldy(value, [[ [fn_1, ...args], [fn_2, ...args], ... ,[fn_n, ...args]] ]).then( val => )
where value
is the first argument of the first function (// TODO: to improve).
License
MIT