JSPM

  • Created
  • Published
  • Downloads 15601936
  • Score
    100M100P100Q215153F
  • License MIT

A minimal and fast promise implementation

Package Exports

  • lie

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lie

Promises/A+ logo

lie is a JavaScript promise/deferred implementation, implementing the Promises/A+ spec, with the goal of implementing the spec as closely as possible and nothing else, this means created promises only have a then method and promises may only be created by passing a resolver function to the constructor. Lie is not meant to compete with Q, When, or any of the other promise libraries that already exist, it is meant to be a library you could use to create a Q or When style tool belt, which I did over here.

A fork of Ruben Verborgh's library called promiscuous. Which takes advantage of my immediate library, uses object constructors, and with a name I can actually consistently spell. Plus if I learned anything from catiline (formally communist) it's that you don't want to pick an even mildly offensive name.

API

by defailt adds a function called 'Promise' to the global scope (or if you grab the noConflict version than one called lie)

return a promise

function waitAwhile(){
    return promise(function(resolve,reject){
        doSomething(functin(err,result){
            if(err){
                reject(err);
            }else{
                resolve(result);
            }
        });
    });
}

Write a function turns node style callback to promises

function denodify(func){
    return function() {
        var args = Array.prototype.concat.apply([], arguments);
        return promise(function(resolve, reject) {
            args.push(function(err, success) {
                if (err) {
                    reject(err);
                }
                else {
                    resolve(success);
                }
            });
            func.apply(undefined, args);
        });
    };
};

##node

install with npm install lie, exactly the same as above but

var promise = require('lie');