Skip to content
⚡️ Promisify methods on the prototype of an object
Branch: master
Clone or download
Pull request Compare This branch is 11 commits ahead, 30 commits behind sindresorhus:master.
Latest commit a25ea02 Mar 28, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig tweaks (sindresorhus#20) Apr 17, 2016
.gitignore Refactor to pify-proto Jun 15, 2016
index.js Add multiArgs option as per pify (#2) Mar 28, 2017
license Refactor to pify-proto Jun 15, 2016
optimization-test.js Refactor to pify-proto Jun 15, 2016
package.json v0.2.0 Mar 28, 2017
test.js Add multiArgs option as per pify (#2) Mar 28, 2017


Promisify methods on the prototype of an object

npm version

  • Exclusively for promisfying enumerable methods on a prototype
  • Does not modify the original object prototype; returns a copy with a new prototype*
  • Only include/exclude/multiArgs options (I don't need the others; always open to PRs)

* In order that the lib can operate normally if it uses any method internally (because it will be passing callbacks as per original method signature).

Credit goes to Sindre Sorhus and other contributors of pify, for which this is a fork. Thanks y'all!


$ npm install --save pify-proto


const pify = require('pify-proto');

class SomeConstructor {
  constructor () { = 'bar'
  baz (cb) {

// promisify prototype of an object

const inst = pify(new SomeConstructor())

//=> 'foo'


pify(input, [promiseModule], [options])

Returns a new object with prototype methods on obj promisified.


Type: object

The object to promisify.


Type: function

Custom promise module to use instead of the native one.

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



Type: array of (string|regex)

Methods in a module to promisify. Remaining methods will be left untouched.


Type: array of (string|regex)
Default: [/.+Sync$/]

Methods in a module not to promisify. Methods with names ending with 'Sync' are excluded by default.


Type: boolean
Default: false

By default, the promisified methods will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like oauth with prototype methods that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument.

const OAuth = require('oauth').OAuth;
const pify = require('pify-proto');

const oauth = pify(new OAuth(
    'blah blah'
), {multiArgs: true});

.then(result => {
	const [ oauth_token, oauth_secret ] = result;

Authors & License

pify was created by Sindre Sorhus.

pify-proto was created by Sam Gluck.

pify-proto contributors:

pify-proto is released under the MIT license.

You can’t perform that action at this time.