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

bind-obj-methods

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bind-obj-methods - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

38

bind-obj-methods.js

@@ -1,10 +0,8 @@

module.exports = bindObj
'use strict'
function bindObj (obj, proto, bound) {
module.exports = (obj, proto, bound) => {
bound = bound || Object.create(null)
if (Array.isArray(bound))
bound = bound.reduce(function (set, k) {
set[k] = true
return set
}, Object.create(null))
bound = bound.reduce((s, k) => (s[k] = true, s), Object.create(null))

@@ -15,20 +13,14 @@ // don't try to bind constructors, it's weird

Object.keys(proto).forEach(function (k) {
if (typeof obj[k] === 'function' && !bound[k]) {
bound[k] = true
obj[k] = proto[k].bind(obj)
}
})
Object.keys(proto)
.filter(k => (typeof obj[k] === 'function' && !bound[k]))
.forEach(k => (bound[k] = true, obj[k] = proto[k].bind(obj)))
Object.getOwnPropertyNames(proto).forEach(function (k) {
if (typeof obj[k] === 'function' && !bound[k]) {
bound[k] = true
Object.defineProperty(obj, k, {
value: obj[k].bind(obj),
enumerable: false,
configurable: true,
writable: true
})
}
})
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": "1.0.0",
"version": "2.0.0",
"description": "Bind methods to an object from that object or some other source. Optionally specify a set of methods to skip over.",
"main": "bind-obj-methods.js",
"scripts": {
"test": "node test.js"
"test": "tap test.js --100",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags"
},

@@ -19,3 +22,7 @@ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",

},
"homepage": "https://github.com/isaacs/bind-obj-methods#readme"
"homepage": "https://github.com/isaacs/bind-obj-methods#readme",
"devDependencies": {
"tap": "^10.7.0"
},
"files": []
}

@@ -31,3 +31,4 @@ # bind-obj-methods

bindObjMethods(obj)
m = obj.method
m() // 'bar'
```
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