JSPM

  • Created
  • Published
  • Downloads 15620312
  • Score
    100M100P100Q215851F
  • 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, and now in v2 using syntax more inline with what is going into es6.

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);
            }
        });
        function.apply(undefined,args);
    });
  }
}

##node

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

var promise = require('lie');