1.0.0 • Published 8 years ago
node-apply v1.0.0
apply
a simpler way to create a continuation function with initial arguments and then be called with the remaining arguments
api
apply(function_to_apply, initial_arguments)
examples
first example
const apply = require('node-apply')
const foo = apply(puts, 'one')
foo('two', 'three')// will return `one two three`
function puts (one, two, three) {
return `${one} ${two} ${three}`
}
second example
const apply = require('node-apply')
const async = require('lasync')
async.waterfall(
[
apply(putsAsync, 'one'),
apply(putsAsync, 'two'),
apply(putsAsync, 'three')
],
(err, res) => {
// res will be 'one - two - three'
}
)
function putsAsync (...args) {
let cb = args.pop()
cb(null, args.reverse().join(' - '))
}
ISC License (ISC)
1.0.0
8 years ago