Eric Foster d5378345de connection between front end and database | 6 jaren geleden | |
---|---|---|
.. | ||
dist | 6 jaren geleden | |
lib | 6 jaren geleden | |
test | 6 jaren geleden | |
.jshintrc | 6 jaren geleden | |
.npmignore | 6 jaren geleden | |
.travis.yml | 6 jaren geleden | |
AUTHORS | 6 jaren geleden | |
README.md | 6 jaren geleden | |
bower.json | 6 jaren geleden | |
component.json | 6 jaren geleden | |
license.md | 6 jaren geleden | |
package.json | 6 jaren geleden | |
polyfill.js | 6 jaren geleden |
<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 a small, performant, promise library implementing the Promises/A+ spec Version 1.1.
A originally a fork of Ruben Verborgh's library called promiscuous, version 2.6 and above are forked from 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
Promise
will be available through a CJS or AMD loader if it's available instead)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 lie emits unhandledRejection
events when promises are not handled in
line with how iojs does so
meaning it can act as promise shim in node as well as the browser.