promisiphy
v0.0.3
Published
Promisifier to handle thunks in es6 style
Downloads
4
Maintainers
Readme
Simple ES6 promisifier
Turns old-style-callback function to the Promise-style one
Basic usage
const promisify = require('promisiphy');
const fs = require('fs');
promisify(fs, 'stat', 'path/to/the/file')
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
Providing a context
const promisify = require('promisiphy');
const http = require('http');
promisify(http, 'get', 'http://some.url', {ctx: http})
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});