Package Exports
- putil-promisify
- putil-promisify/lib/promisify.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (putil-promisify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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;