1.0.7 • Published 5 years ago

promison v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

Expect to generate data from asynchronous apis like blow:

async function get() {
  const result = {
    v1: await Promise.resolve('v1'),
    v2: { value: await Promise.resolve('v2') },
    v3: { v3: [ 1, 2, 3 ].map(i => await Promise.resolve(i))},
  };

  return result;
}

In these codes, these promises will be executed one by one, not in a concurrent way.But if you use Promise.all, the code will be much more complicated because you hava to deal with the Promise.all's result array. Then let's try promison:

const promison = require('promison');
async function get() {
  const data = {
    v1: Promise.resolve('v1'),
    v2: Promise.resolve({value: 'v2'}),
    v3: { arr: [ 1, 2, 3 ].map(i => Promise.resolve(i))},
  };

  const result =  await promison(data);
  return result;
}

It's easy to use and the procedure will be much more clear.

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago