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.1 to 1.0.2

.travis.yml

11

index.js

@@ -5,5 +5,9 @@ const { promisify } = require('util')

for (const key of Object.getOwnPropertyNames(object)) {
const func = object[key]
if (typeof func === 'function') {
object[`${key}Async`] = promisify(func)
const descriptor = Object.getOwnPropertyDescriptor(object, key)
if (!descriptor.get) {
const func = object[key]
if (typeof func === 'function') {
object[`${key}Async`] = promisify(func)
}
}

@@ -13,3 +17,2 @@ }

module.exports = function (object) {

@@ -16,0 +19,0 @@ _promisifyAllFunctions(object)

{
"name": "util-promisifyall",
"version": "1.0.1",
"version": "1.0.2",
"description": "promisifyAll with node's native promisify function",

@@ -10,3 +10,4 @@ "main": "index.js",

"scripts": {
"test": "mocha test"
"test": "nyc mocha test",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},

@@ -28,4 +29,7 @@ "repository": {

"devDependencies": {
"mocha": "^3.4.2"
"coveralls": "^2.13.1",
"mocha": "^3.4.2",
"nyc": "^11.0.2",
"redis": "^2.8.0"
}
}
const assert = require('assert')
const Redis = require('redis')

@@ -31,3 +32,3 @@ const promisifyAll = require('../index')

}
_testPromisification(object)
await _testPromisification(object)
})

@@ -46,4 +47,51 @@

const object = new MyClass()
_testPromisification(object)
await _testPromisification(object)
})
context('when directly promisifing a prototype', () => {
it('should all functions defined on an object\'s prototype', async () => {
class MyClass {
someFunc (input, callback) {
callback(null, input)
}
}
promisifyAll(MyClass.prototype)
const instance = new MyClass()
const input = 'input'
const result = await instance.someFuncAsync(input)
assert(result === input, 'result should match input')
})
})
context('objects with function getters', () => {
const propertyName = 'someProperty'
let testObject
beforeEach(() => {
testObject = {
someOtherProperty: false,
someFunc (input, callback) {
callback(null, input)
}
}
Object.defineProperty(testObject, propertyName, {
get: function () {
throw new Error('Should not triggered')
}
})
})
it('should be able to promisify objects that contain properties with ' +
'getter functions', async () => {
promisifyAll(testObject)
const input = 'input'
const result = await testObject.someFuncAsync(input)
assert(result === input, 'result should match input')
})
})
})

Sorry, the diff of this file is not supported yet

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