New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

util-promisifyall

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-promisifyall - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

11

index.js
const { promisify } = require('util')
const functionBlackListMap =
Object.getOwnPropertyNames(Object.prototype)
.reduce(function (map, functionName) {
map[functionName] = true
return map
}, {});
function _promisifyAllFunctions (object) {
for (const key of Object.getOwnPropertyNames(object)) {
if (functionBlackListMap[key]) {
continue;
}
const descriptor = Object.getOwnPropertyDescriptor(object, key)

@@ -6,0 +17,0 @@

5

package.json
{
"name": "util-promisifyall",
"version": "1.0.2",
"version": "1.0.3",
"description": "promisifyAll with node's native promisify function",

@@ -30,5 +30,4 @@ "main": "index.js",

"mocha": "^3.4.2",
"nyc": "^11.0.2",
"redis": "^2.8.0"
"nyc": "^11.0.2"
}
}

22

test/test.js
const assert = require('assert')
const Redis = require('redis')

@@ -49,2 +48,23 @@ const promisifyAll = require('../index')

it('should not promisify any functions on the default object prototype', () => {
class MyClass {
someFunc (input, callback) {
callback(null, input)
}
someOtherFunc (input, callback) {
callback(null, input)
}
}
const NewClass = promisifyAll(MyClass.prototype)
const propertyNames = Object.getOwnPropertyNames(Object.prototype)
for (const key in Object.getPrototypeOf(NewClass)) {
const asyncName = key + 'Async'
assert(propertyNames.indexOf(asyncName) === -1,
`Error: class prototype should not contain ${asyncName}`)
}
})
context('when directly promisifing a prototype', () => {

@@ -51,0 +71,0 @@ it('should all functions defined on an object\'s prototype', async () => {

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