/tinywork

Just do a little tiny work for Promises

Primary LanguageJavaScript

tinywork

只做了一点微小的工作。

NPM version build status Coverage Status David deps npm download

Installation

You can install it as dependency via npm.

$ npm install tinywork --save
// or
$ cnpm install tinywork --save

Usage

tinywork can process mix Promise list or mix Object.

mix object

You can use co and yield like this:

yield tinywork({
  a: Promise.resolve(1),
  b: Promise.resolve(2),
  c: 'c'
});

// =>
{
  a: 1,
  b: 2,
  c: 'c'
}

And use async/await like this:

await tinywork({
  a: Promise.resolve(1),
  b: Promise.resolve(2),
  c: 'c'
});

// =>
{
  a: 1,
  b: 2,
  c: 'c'
}

mix array

You can use co and yield like this:

yield tinywork([
  Promise.resolve(1),
  Promise.resolve(2),
  'c'
]);

// =>
[1, 2, 'c'];

And use async/await like this:

await tinywork([
  Promise.resolve(1),
  Promise.resolve(2),
  'c'
]);

// =>
[1, 2, 'c'];

Others

Just return resolved Promise with value.

License

The MIT license