Skip to content

BoryaMogila/promise-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors