promiseo
v0.1.2
Published
Library for resolve object of promises
Downloads
4
Readme
promiseo
Library for resolve object with promises
Install
npm install promiseo --save-dev
Usage
import promiseo from 'promiseo'
const somePromiseFunction = new Promise((resolve) => {
...
resolve('test')
})
const someAsyncFunction = async () => {
...
return ['1', '2']
}
const someAsyncFunctionThatReturnsObject = async () => {
...
return {
param1: 1
param2: 2
}
}
const result = promiseo({
foo: somePromiseFunction(),
bar: someAsyncFunction(),
simpleString: 'foo', // simple type param
simpleObject: { test: 1 }, // simple object
'...': someAsyncFunctionThatReturnsObject()
})
The result will be
{
foo: 'test',
bar: ['1', '2']
simpleString: 'foo',
simpleObject: { test: 1 },
param1: 1,
param2: 2
}