Promisify Node
Stable: 0.1.3
Maintained by Tim Branyen @tbranyen.
Wraps Node modules, functions, and methods written in the Node-callback style to return Promises.
Install
npm install promisify-node
Examples
Wrap entire Node modules recursively:
var promisify = ;var fs = ;// This function has been identified as an asynchronous function so it has// been automatically wrapped.fs;
Wrap a single function:
var promisify = ;{;}// Convert the function to return a Promise.var wrap = ;// Invoke the newly wrapped function.;
Wrap a method on an Object:
var promisify = ;var myObj ={;};// No need to return anything as the methods will be replaced on the object.;// Intentionally cause a failure by passing an object and inspect the message.myObj;
Tests
Run the tests after installing dependencies with:
npm test