promissory

1.0.2 • Public • Published

Promissory

Turn a regular node function into one which returns an ES6 Promise. This can also be used with generator-based flow control such as co.

This project is a direct port of tj/thunkify. Instead of creating thunks, it creates promises.

This is tested with Node v0.10 up to v5. A Promise polyfill is required to be set globally on v0.10.

Installation

$ npm install promissory

Example

var promisify = require('promissory').promisify;
var fs = require('fs');
 
var readPromissory = promisify(fs.readFile);
 
readPromissory('package.json', 'utf8').then(function(str) {
    console.log('str');
}, function(err) {
    console.error(err);
});

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    318
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    318
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i promissory

Weekly Downloads

318

Version

1.0.2

License

MIT

Last publish

Collaborators

  • basicdays