callback-to-promise-operator

0.0.1 • Public • Published

Callback-To-Promise Operator

npm version Build Status

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);
  });

Package Sidebar

Install

npm i callback-to-promise-operator

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • volune