JSPM

promise-resolver

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 45
  • Score
    100M100P100Q53996F
  • License MIT

Turn a promises resolver methods into a node style callback

Package Exports

  • promise-resolver

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (promise-resolver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

promise-resolver Build Status

Turn a promises resolver methods into a node style callback

Install

$ npm install --save promise-resolver

Usage

var promiseResolver = require('promise-resolver');

new Promise(function (resolve, reject) {
  var cb = promiseResolver(resolve, reject, passThroughCallback);
  
  cb(new Error('...')); // rejects promise and calls passThroughCallback with same args
  cb(null, 'result'); // resolves promise and calls passThroughCallback with same args
});

API

promiseResolver(resolve, reject, passThrough)

All arguments should be functions, null, or undefined.

  • resolve - promise resolve function
  • reject - promise reject function
  • passThrough - a "pass through" node style (error first) callback.

Returns a node style callback: cb(err, result...)

Calling the callback will resolve or reject the promise (depending on the err argument). If it exists, the passThrough callback will be called with the same arguments.

License

MIT © James Talmage