promise-all-obj
v1.0.0
Published
Promise all from object input
Downloads
8
Readme
promise-all-obj
Promise All from Object
Requirements
- Polyfill Promise on old browsers
Features
- Promise.all({...})
Module Installation
$ npm install --save @antoninlanglade/promise-all-obj
Usage
import PromiseAllObj from 'promise-all-obj' // web
// or
const PromiseAllObj = require('promise-all-obj') // node
var testObj = {
promise1: new Promise((res, rej) => {
setTimeout(() => res('p1'), 2000)
}),
promise2: new Promise((res, rej) => res('p2'))
};
PromiseAllObj(testObj)
.then((results) => console.log(results)) // {promise1: 'p1', promise2: 'p2'}
.catch((err) => console.log(err)) // Errors