node package manager


Wrap Node.js callback functions in functional promises


Wraps functions that want callbacks in pure functional promises.

var async = require('fantasy-async');
var get = async(request);
var write = async(fs.writeFile);
var requestPromise = get('/post/123')
.chain(function(post) { return get('/user/'; })
    function error() { return Result.notFound() },
    function done(user) { return Result.ok(JSON.stringify(user)) }

npm install fantasy-async

Given a function that takes a Node-style function (err, result) callback, returns a function that takes the same arguments and returns an EitherT Promise wrapping the error as Left or the result as Right.

See the code for EitherT for the complete API.