0.1.2 • Published 4 years ago

promiseo v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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
  }

License

MIT