0.0.1 • Published 7 years ago

callback-to-promise-operator v0.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

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