bind-obj-methods
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -13,29 +13,14 @@ 'use strict' | ||
for (const k of Object.getOwnPropertyNames(proto)) { | ||
if (bound[k]) { | ||
continue | ||
} | ||
Object.keys(proto) | ||
.filter(k => (typeof obj[k] === 'function' && !bound[k])) | ||
.forEach(k => (bound[k] = true, obj[k] = proto[k].bind(obj))) | ||
const descriptor = {...Object.getOwnPropertyDescriptor(proto, k)}; | ||
if ('value' in descriptor) { | ||
if (typeof descriptor.value !== 'function') { | ||
continue | ||
} | ||
descriptor.value = descriptor.value.bind(obj); | ||
if (!descriptor.configurable) { | ||
if (!descriptor.writable) { | ||
continue; | ||
} | ||
obj[k] = descriptor.value; | ||
bound[k] = true; | ||
continue; | ||
} | ||
bound[k] = true; | ||
Object.defineProperty(obj, k, descriptor) | ||
} | ||
} | ||
Object.getOwnPropertyNames(proto) | ||
.filter(k => (typeof obj[k] === 'function' && !bound[k])) | ||
.forEach(k => (bound[k] = true, Object.defineProperty(obj, k, { | ||
value: obj[k].bind(obj), | ||
enumerable: false, | ||
configurable: true, | ||
writable: true | ||
}))) | ||
} |
{ | ||
"name": "bind-obj-methods", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"publishConfig": { | ||
"tag": "v2-legacy" | ||
}, | ||
"description": "Bind methods to an object from that object or some other source. Optionally specify a set of methods to skip over.", | ||
@@ -24,8 +27,5 @@ "main": "bind-obj-methods.js", | ||
"devDependencies": { | ||
"tap": "^15.0.0-2" | ||
"tap": "^10.7.0" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"files": [] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
3034
20