JSPM

backthen

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q34234F
  • License MIT

Run a callback as a thenable

Package Exports

  • backthen

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 (backthen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

backthen

build status codecov Code Climate

Run a callback as a thenable

Usage

var backthen = require('backthen');
var fs = require('fs');

/*
 * @param {function} func - function to call
 * @param {object} scope - scope for func
 * @param {...any} params - parameters for the function
 *
 * @return {Promise} 
 */
backthen(fs.stat, null, 'file.txt')
  .then(statFulfilled)
  .catch(statRejected)

// Receives array if callback
// invoked with multiple params;
// otherwise a single value
function statFulfilled(stat) {
  // handle the fulfillment
}

function statRejected(err) {
  // handle the rejection
}