JSPM

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

Promisify a callback-based function

Package Exports

  • thenify

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

Readme

thenify

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Promisify a callback-based function.

  • Preserves function names
  • Uses a native promise implementation if available and tries to fall back to bluebird
  • Converts multiple arguments from the callback into an Array
  • Resulting function never deoptimizes

An added benefit is that thrown errors in that async function will be caught by the promise!

API

var thenify = require('thenify');

var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
  callback(null, a, b, c);
});

var fn = thenify([name], fn)

Promisifies a function. Optionally set a custom name to the function, defaulting to fn.name.