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 1.0.0 to 1.1.0

22

index.js
'use strict';
module.exports = function (fn, P) {
function isFn(fn) {
return ({}).toString.call(fn) === '[object Function]';
}
var pify = module.exports = function (fn, P) {
P = P || Promise;
if (({}).toString.call(fn) !== '[object Function]') {
if (!isFn(fn)) {
throw new TypeError('Expected a function');

@@ -28,1 +33,14 @@ }

};
pify.all = function (module, P) {
var ret = {};
for (var method in module) {
if (({}).hasOwnProperty.call(module, method)) {
var x = module[method];
ret[method] = isFn(x) ? pify(x, P) : x;
}
}
return ret;
};

2

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

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

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

});
// promisify all methods in a module
var promiseFs = pify.all(fs);
promiseFs.readFile('package.json', 'utf8').then(function (data) {
console.log(JSON.parse(data).name);
//=> 'pify'
});
```

@@ -41,2 +49,12 @@

### pify.all(module, [promiseModule])
Returns a version of the module with all its methods promisified.
#### module
Type: `object`
Module whose methods you want to promisify.
#### promiseModule

@@ -43,0 +61,0 @@

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