plumb
Version:
functional composition sugar
77 lines (45 loc) • 1.69 kB
Markdown
functional composition sugar
var plumb = require('plumb')
var reverseString = plumb(
plumb.invoke('split')
plumb.invoke('reverse')
plumb.invoke('join','')
)
// => Function
reverseString('hello')
// => "olleh"
Using [jsig notation](https://github.com/jden/jsig)
Reutrns a function composing each of the argument functions in order. The return value of each function is used as the argument for each successive function.
Immediately invoke a composition of functions `fns` on the value `val`. It helps me to think about `fns` as a crazy pachinko machine and `val` as the ball going in.
Equivalent to `plumb(fns)(val)`
Creates a function which invokes a method on an object, optionally with fixed arguments.
Example:
plumb.invoke('foo','bar')
returns the equivalent of
function callFoo(obj) {
return obj.foo('bar')
}
Create a function which passes a value through (identity) and calls a function `fn` with that value.
Example:
var log = plumb.tap(function (x) { console.log(x)})
log(10)
// => 10
// side effect: console.log(10) was called
$ npm install plumb
From project root:
$ npm install
$ npm test
jden <jason@denizac.org>
MIT. (c) 2013 Agile Diagnosis <hello@agilediagnosis.com> See LICENSE.md
"...and visions of sugarplums danced in their heads"