Socket
Socket
Sign inDemoInstall

pify

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

10

index.js

@@ -55,2 +55,10 @@ 'use strict';

var ret = (typeof obj === 'function') ? function () {
if (opts.excludeMain) {
return obj.apply(this, arguments);
}
return pify(obj, P, opts).apply(this, arguments);
} : {};
return Object.keys(obj).reduce(function (ret, key) {

@@ -60,3 +68,3 @@ var x = obj[key];

return ret;
}, {});
}, ret);
};

2

package.json
{
"name": "pify",
"version": "2.1.0",
"version": "2.2.0",
"description": "Promisify a callback-style function",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -98,5 +98,37 @@ # pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify)

##### excludeMain
Type: `boolean`
Default: `false`
*Works for `pify.all()` only.*
By default, if given `module` is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module.
```js
const pify = require('pify');
function fn() {
return true;
}
fn.method = (data, callback) => {
setImmediate(() => {
callback(data, null);
});
};
// promisify methods but not fn()
const promiseFn = pify.all(fn, {excludeMain: true});
if (promiseFn()) {
promiseFn.method('hi').then(data => {
console.log(data);
});
}
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc