A basic but performant promise implementation.
JavaScript HTML
Pull request Compare This branch is 56 commits behind calvinmetcalf:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
lib
test
.gitignore
.jshintrc
.travis.yml
AUTHORS
README.md
bower.json
component.json
license.md
package.json

README.md

lie

Promises/A+ logo [![Build Status](https://travis-ci.org/calvinmetcalf/lie.svg)](https://travis-ci.org/calvinmetcalf/lie)

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');

Usage

Either use it with browserify (recommended) or grab one of the files from the dist folder

  • lie.js/lie.min.js makes 'Promise' available in global scope (or since it's a UMD Promise will be availble through a CJS or AMD loader if it's available instead)
  • lie.noConflict.js/lie.noConflict.min.js makes 'Lie' available in global scope, otherwise they are the same as lie.js/lie.min.js
  • lie.polyfill.js/lie.polyfill.min.js adds 'Promise' to the global scope only if it's not already defined (not a UMD).

API

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