node-promise-back
v1.0.0
Published
Allow to easily use promises wherever you should use standard callback
Downloads
2
Readme
node-promise-back
Easily wraps deferred/promise to be used in functions requiring callback function.
Works with
- kriskowal/q
- petkaantonov/bluebird
- native Promise
Install
npm install --save node-promise-back
Usage
See tests.
Q
var fs = require('fs'),
promiseBack = require('node-promise-back'),
q = require('q'),
deferred = q.defer();
fs.readFile('path.txt', 'utf8', promiseBack(deferred));
deferred.then(...);
BlueBird
var fs = require('fs'),
promiseBack = require('node-promise-back'),
Promise = require('bluebird'),
callback = promiseBack.native(Promise);
fs.readFile('path.txt', 'utf8', callback);
callback.promise.then(...);
Native
var fs = require('fs'),
promiseBack = require('node-promise-back'),
callback = promiseBack.native();
fs.readFile('path.txt', 'utf8', callback);
callback.promise.then(...);
Test
mocha
Autor
[email protected] / sielay.com
Contribute
Fork -> Fix -> Test -> Pull Request
License
MIT of course