Promises and operations over them; useful utility functions.
Practical algorithms for node.js and browsers operating on any Promises (any
then()-able will do, including ES6's
all()— similar to standard
Promise.all(). Returns an array of results, or fails with a first failed promise.
par()— collects all results into an array, both normal values, and errors. Never fails.
one()— similar to standard
Promise.race(). Resolves or fails with the first fulfilled promise.
any()— resolves with a first resolved promise. Failed promises are ignored unless all of them have failed. In the latter case it fails with the value of the first one in the array.
seq()— a helper to run asynchronous operations sequentially one after another.
whilst()— a generalized asynchronous loop.
when()— adapt any value (
then()-able, or a plain value) to a promise.
promisify()— adapt node.js asynchronous callback-style functions to promise-based functions.
timeout()— resolve or reject a value after a timeout. If combine with other composition operations, like
race(), it can help to implement any time-dependent conditions, e.g., timeouts on operations.
Deferred— fast deferred implementation without built-in timeouts unlike A+ Promises. Implements progress reports, and cancellations. Very helpful for debugging because it preserves call stacks.
FastDeferred— just like
Deferredbut even faster, because it doesn't convert exceptions into failed promises implicitly. It allows to JIT all of its code, and helps to debug unexpected exceptions.
npm install --save heya-async
bower install --save heya-async
All documentation can be found in project's wiki.
To get more information on underlying concepts:
Included algorithms (work across all type of promises):
Included implementations of deferreds (can be used instead or alongside with the standard
BSD or AFL — your choice
For information on all pre-1.0.0 versions, please see the commit log.