node package manager

swear

recursive promise resolution

swear

a more flexible Promise.all

const fetch = require('isomorphic-fetch')
const swear = require('swear')
 
swear({
  obj: fetch('/json').then(res => res.json()), 
  numbers: [1, 2, new Promise(resolve => resolve(3))],
  wut: new Promise(resolve => resolve({a: new Promise(resolve => resolve('b'))}))
}).then(x => {
  // {obj: {api: 'result'}, numbers: [1, 2, 3], wut: {a: 'b'}} 
})
  • If any promise rejects, the returned promise will immediately reject.

swear(x) -> Promise

  • x can be basically anything.

MIT