1.1.1 • Published 5 years ago

p-join v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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

1.1.1

5 years ago

1.1.0

7 years ago

1.0.0

7 years ago