wellfirst
v1.0.2
Published
Converts a standard error-first callback async node function into a native Promise.
Downloads
3
Readme
#wellfirst
Usage
wellFirst(asyncFunction, 'arguments', 'to', 'your', 'function')
.then
will call its provided function with a single argument of an array-like object of the results of the would-be callback.
npm install wellfirst
var wellFirst = require('wellfirst');
var fs = require('fs');
console.log('EXECUTE PROMISE');
console.log(Date.now());
wellFirst(fs.stat, 'wellfirst.js')
.then(function(result){
console.log(Date.now());
console.log('END PROMISE');
})
.then(function(){
console.log('EXECUTE PROMISE');
console.log(Date.now());
return wellFirst(fs.stat, 'wellfirst.js')
})
.then(function(result){
console.log(Date.now());
console.log('END PROMISE');
console.log('EXECUTE CALLBACK');
console.log(Date.now());
fs.stat('wellfirst.js', function(err, result){
console.log(Date.now());
console.log('END CALLBACK');
})
})