XuelesszzZ 94af2b8e7b 6-30-5 | 1 year ago | |
---|---|---|
.. | ||
dist | 1 year ago | |
lib | 1 year ago | |
README.md | 1 year ago | |
license.md | 1 year ago | |
lie.d.ts | 1 year ago | |
package.json | 1 year ago | |
polyfill.js | 1 year ago |
<img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"
alt="Promises/A+ logo" title="Promises/A+ 1.1 compliant" align="right" />
lie is a small, performant promise library implementing the Promises/A+ spec (Version 1.1).
Originally a fork of Ruben Verborgh's promiscuous, with version 2.6 it became a fork of ayepromise by Chris Burgmer.
npm install lie
var Promise = require('lie');
// or use the pollyfill
require('lie/polyfill');
Either use it with browserify (recommended) or grab one of the files from the dist folder:
Implements the standard ES6 api:
new Promise(function(resolve, reject){
doSomething(function(err, result) {
if (err) {
reject(err);
} else {
resolve(result);
}
});
}).then(function (value) {
//on success
}, function (reason) {
//on error
}).catch(function (reason) {
//shortcut for error handling
});
Promise.all([
//array of promises or values
]).then(function ([/* array of results */]));
Promise.race([
//array of promises or values
]);
// either resolves or rejects depending on the first value to do so
In Node.js, lie emits an unhandledRejection
event when a rejected promise isn't caught, in line with how io.js does it. This allows it to act as a promise shim in both Node.js and the browser.