2.0.1 • Published 6 years ago
promise-all-object v2.0.1
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);
}
}