putil-promisify
v1.10.1
Published
Simple and lightweight utility for transforming callback functions to Promises
Downloads
232,841
Maintainers
Readme
putil-promisify
Simple and lightweight utility fore transforming callback functions to Promises
Installation
npm install putil-promisify --save
Usage
promisify(resolver)
const Promisify = require('./');
const fs = require('fs');
// Transform callback function to promise
const promise = Promisify.fromCallback((cb) => {
fs.readdir('./', cb);
});
// Do what ever you want with promise
promise.then(result => {
console.log(result);
}).catch(e => {
console.error(e);
});
Node Compatibility
- node
>= 6.x
;