0.8.0 • Published 7 years ago
impossible-promise v0.8.0
(IM)POSSIBLE PROMISE
wrapper used to chain native Promises in an async sequence
Instal from NPM
requires node -v >4.3.2 (for Promises support)
$ npm install impossible-promise
Usage:
use new sequence()
and .then()
to chain promises
use .done()
to fetch all results
var sequence = require("impossible-promise")
new sequence((next,reject) => {
next("giving");
}).then((next,reject) => {
setTimeout(() => next("is") , 1000);
}).then((next,reject) => {
next("caring!");
}).done((a,b,c) => {
console.log([a,b,c].join(" "));
// => giving is caring!
});
Documentation
check test.js for examples
TODO:
- propper documentation
- backwards compatibility
- browser compatibility
- support for
Promise.race()
- support for
Promise.all()
- added .promisify()
- added .pipe()
- allows new ImpossibePromise() without arguments
- allows .then(new ImpossibePromise())
- allows multiple .done()
- write a CONTRIBUTING.file
LICENSE
MIT, see LICENSE for details.