node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »


Node To Prescription

This is a convenience wrapper libary to make converting asynchronous node.js callback style functions to FRP Prescription functions that return Observable's mostly one liners.


var Observable         = require("prescription").Observable;
var nodeToPrescription = require("node-to-prescription");
// A typical node.js callback driven asynchronous function 
var doAsync = function(data, next) {
    process.nextTick(function() {
        next(null, "async done: " + data);
// Here we wrap the node.js async function to return an Observable 
var observableAsync = nodeToPrescription(doAsync);
// Here we issue an async call, get an Observable back, map over the results 
// and finally print the result to the console. 
observableAsync("joseph").map(function(n) { return n.toUpperCase(); });
                         .subscribe(function(m) { console.log(n); });