promisify.es6
Promisify a callback-based function.
Why Another Promisify Module?
Only 10 LOC (and, therefore, much smaller than
node-promisify
andpromisify-node
, for example).Simple and clean code (thanks to ES6 features, such as, arrow functions and the spread operator).
No dependencies.
100% test coverage.
Installation
npm install --save promisify.es6
Example
const promisify = require('promisify.es6')
function sum (a, b, callback) {
callback(null, a + b)
}
let promisifiedSum = promisify(sum)
promisifiedSum(1, 2).then(sum => {
console.log(sum) // --> 3
})
License
WTFPL – Do What the F*ck You Want to Public License.
Made with by @MarkTiedemann.