p-join
combine results from multiple promises into a single value
Last updated 2 years ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install p-join 
SYNC missed versions from official npm registry.

p-join

Combine results from multiple promises into a single value.

Like Promise.join from bluebird.

Installation

With npm:

npm install --save p-join

Usage

var join = require('p-join')

var result = join(
  Promise.resolve(10),
  Promise.resolve(20),
  function (a, b) { return a + b }
)

result.then(function (sum) {
  assert.equal(sum, 30)
})

Compare doing this with Promise.all:

var result = Promise.all([
  Promise.resolve(10),
  Promise.resolve(20)
]).then(function (results) { return results[0] + results[1] })

result.then(function (sum) {
  assert.equal(sum, 30)
})

API

result = require('p-join')(...promises, callback)

Pass Promises or values as separate arguments. The callback receives the resolved values of all ...promises as arguments, in order. If callback returns a value or a Promise, result will resolve with that value.

License

MIT

Current Tags

  • 1.1.1                                ...           latest (2 years ago)

3 Versions

  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |