cpsenize

Wraps synchronous functions with a cps (callback passing style) function

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
cpsenize
2.0.08 years ago9 years agoMinified + gzip package size for cpsenize in KB

Readme

cpsenize
Wraps synchronous functions with a cps (callback passing style) function
var cpsenize = require('cpsenize');

function add(a, b){
    return a + b;
}

var cpsAdd = cpsenize(add);

cpsAdd(5, 6, function(error, result){
    console.log(result); // 11
});

Additionally can also return errors if the function throws
var cpsenize = require('cpsenize');

function add(a, b){
    throw new Error('BANG!!!');
}

var cpsAdd = cpsenize(add, true);

cpsAdd(5, 6, function(error, result){
    console.log(error); // BANG!!!
});