promessa
v1.1.8
Published
Promises library which complies with the Promises/A+ specification, written with a focus towards readability.
Downloads
5
Maintainers
Readme
Promessa
A Node.js Promises library which complies with the Promises/A+ specification. Written with a focus towards readability over high performance and used as a learning exercise to better understand how Promises function and evaluate themselves internally.
Usage
let Promessa = require('promessa');
let myPromise = new Promessa((resolve,reject) => {
// implement here
});
Methods
Promessa implements the following constructor and prototype:
new Promessa(function(resolve,reject) { ... })
Promessa.prototype.then(onFulfilled,onRejected)
Promise.prototype.catch(onRejected)
In addition, the following utility methods are available:
Promessa.resolve(value)
Promessa.reject(reason)
Promessa.all(promiseList)
(withpromiseList
as anArray
)Promessa.race(promiseList)
(withpromiseList
as anArray
)
For use of these methods, I won't repeat what is already available via the excellent MDN Promise documentation.
Tests
Library passes the promises-aplus-tests
suite to meet the Promises/A+ specification. In addition a basic test suite for Promessa.all(promiseList)
and Promessa.race(promiseList)
methods is included.
All tests are run via test/run.sh
.
Reference
Promise implementations/documentation referred to during development:
- https://github.com/then/promise
- https://github.com/abdulapopoola/Adehun
- https://www.promisejs.org/patterns/