callback-to-promise-operator
v0.0.1
Published
An operator that converts asynchronous functions expecting a callback to functions returning a Promise.
Downloads
2
Maintainers
Readme
Callback-To-Promise Operator
An operator that converts asynchronous functions expecting a callback to functions returning a Promise.
Example
// Use whatever variable name that you like for the operator
const $P = require('callback-to-promise-operator').default;
// With an asynchronous function expection a callback
const delayUpperCase = (value, callback) => {
setTimeout(() => callback(null, value.toUpperCase()), 1000);
};
// Use it as if it was returning a Promise
delayUpperCase[$P]('string')
.then((result) => {
console.log(result);
});