git ssb

3+

cel / ssb-npm-registry



Tree: 4f27567900a7b5b821bccc74e95bfc96c8233159

Files: 4f27567900a7b5b821bccc74e95bfc96c8233159 / node_modules / multicb / README.md

891 bytesRaw

MultiCB

Simple way to aggregate multiple node-style callbacks

var multicb = require('multicb')

// default usage

var done = multicb()
doAsync(done())
doAsync(done())
doAsync(done())
done(function(err, results) {
  console.log(err) // => undefined
  console.log(results) /* =>
  [
    [undefined, 'foo'],
    [undefined, 'bar'],
    [undefined, 'baz']
  ]
  */
})

// pluck argument

var done = multicb({ pluck: 1 })
doAsync(done())
doAsync(done())
doAsync(done())
done(function(err, results) {
  console.log(err) // => undefined
  console.log(results) /* =>
  [
    'foo',
    'bar',
    'baz'
  ]
  */
})

// spread argument

var done = multicb({ pluck: 1, spread: true })
doAsync(done())
doAsync(done())
doAsync(done())
done(function(err, a, b, c) {
  console.log(err) // => undefined
  console.log(a) // => 'foo'
  console.log(b) // => 'bar'
  console.log(c) // => 'baz'
})

Built with git-ssb-web