Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pify

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pify - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

18

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

@@ -34,13 +30,11 @@ }

pify.all = function (module, P) {
pify.all = function (obj, 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;
}
}
Object.keys(obj).forEach(function (key) {
var x = obj[key];
ret[key] = typeof x === 'function' ? pify(x, P) : x;
});
return ret;
};
{
"name": "pify",
"version": "1.1.0",
"version": "1.1.1",
"description": "Promisify a callback-style function",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=0.12.0"
"node": ">=0.10.0"
},

@@ -16,0 +16,0 @@ "scripts": {

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

```js
var fs = require('fs');
var pify = require('pify');
const fs = require('fs');
const pify = require('pify');
pify(fs.readFile)('package.json', 'utf8').then(function (data) {
pify(fs.readFile)('package.json', 'utf8').then(data => {
console.log(JSON.parse(data).name);

@@ -26,5 +26,5 @@ //=> 'pify'

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

@@ -31,0 +31,0 @@ //=> 'pify'

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc