1.0.0 • Published 7 years ago

node-apply v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

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)