promise-all-object

2.0.1 • Public • Published

promise-object

Work like Promise.all with objects any nesting level

install

node >= 8

 
npm i -save promise-all-object
 

else node versions and for webpack build

 
npm i -save promise-all-object@1.*
 

test

# test 
node --expose-gc test/test.js
 

usage

const promiseObject = require('promise-all-object');
 
promiseObject({
  op1: asyncOperation(),
  op2: asyncOperation(),
  op3: 'simple field',
  op4: {
    op1: asyncOperation(),
    op2: asyncOperation(),
  },
  op5: [
    asyncOperation(),
    asyncOperation(),
  ]
}).then(res => {
  // do something...
}).catch(e => {
  console.log(e);
});
 
// or
async () => {
  try {
    const res = await promiseObject({
      op1: asyncOperation(),
      op2: asyncOperation(),
      op3: 'simple field',
      op4: {
        op1: asyncOperation(),
        op2: asyncOperation(),
      },
      op5: [
        asyncOperation(),
        asyncOperation(),
      ]
    });
    // do something...
  } catch (e){
    console.log(e);
  }
}
 

Package Sidebar

Install

npm i promise-all-object

Weekly Downloads

99

Version

2.0.1

License

ISC

Last publish

Collaborators

  • boryamogila