npm.io
1.0.0 • Published 9 years ago

node-apply

Licence
ISC
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
1

apply

a simpler way to create a continuation function with initial arguments and then be called with the remaining arguments


Build StatusCode Coverage 100%ISC LicenseNodeJS

JavaScript Style Guide

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)

Keywords