JSPM

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

Promisify a callback-style function

Package Exports

  • pify

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

Readme

pify Build Status

Promisify a callback-style function

Install

$ npm install --save pify

Usage

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

pify(fs.readFile)('package.json', 'utf8').then(function (data) {
    console.log(JSON.parse(data).name);
    //=> 'pify'
});

API

pify(input, [promiseModule])

Returns a promise wrapped version of the supplied function.

If the callback of the supplied function gets more than two arguments the result will be an array.

input

Type: function

Callback-style function.

promiseModule

Type: function

Custom promise module to use instead of the native one.

Check out pinkie-promise if you need a tiny promise polyfill.

License

MIT © Sindre Sorhus