drainpipe
utility for piping a value through a chain of functions
v * 2 v + 2 console// =>48
api
vv(x)
Takes in a value and starts a chain.
vv(x)(fn[, arg1[, arg2[, ...]]])
Takes in a function and optional extra arguments, calls the function with the current value in the drainpipe chain and stores its result as the new value in the drainpipe chain.
{ return a + b} add 1 add 3 console // 27
vv(x)()
Returns the current value in the drainpipe chain
var x = v * 2 v + 2 console // 48
install
You can use this library as the npm package drainpipe
:
npm i drainpipe
# or
yarn add drainpipe
It can be used in both es-module-aware and commonjs bundlers/environments.
// es module // commonjsconst vv =
It can also be used a <script>
: