@jacobmarshall/callback-promise
v0.0.1
Published
A simple promise utility to assist with third party node-style callback functions.
Downloads
1
Readme
@jacobmarshall/callback-promise
Instead of using a utility like Bluebird's promisify to create a version of function(s) which return a Promise, this utility allows you to create a special object which can be passed into a function which accepts a node-style callback, and can also be used as a Promise.
If that doesn't make sense, check out this "simple" example.
import fs from 'fs';
import callbackPromise from '@jacobmarshall/callback-promise';
async function example() {
const passwords = callbackPromise();
fs.readFile('/etc/passwd', passwords);
console.log('Passwords: ' + await passwords);
}
example();
License
MIT