1.6.0 • Published 4 years ago
@tuplo/asyncary v1.6.0
asyncary
Asynchronous utility library
Install
$ npm install @tuplo/asyncary
# or with yarn
$ yarn add @tuplo/asyncary
Usage
seriesWith
import { seriesWith } from '@tuplo/asyncary';
const fn = (n) => Promise.resolve(n * 2);
await seriesWith<number>([1, 2, 4], fn); // → [2, 4, 8]
API
seriesWith<T>(collection, iteratee)
Creates an array of values by running each element in collection
thru iteratee
, each one running once the previous iteration has completed.
collection: T[]
A list of items to be iterated on.
iteratee: (x: unknown) => Promise<T> | T
An asynchronous or synchronous function to apply for each item in collection
.
return value: Promise<T[]>
A Promise returning a list of items resulting from applying iteratee
on each item on collection
, each only after the previous settled.
Contribute
Contributions are always welcome!
License
MIT