2.0.1 • Published 6 years ago

promise-all-object v2.0.1

Weekly downloads
168
License
ISC
Repository
github
Last release
6 years ago

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);
  }
}
2.0.1

6 years ago

1.0.4

6 years ago

2.0.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

7 years ago