Bind all methods in an object
$ npm install --save bind-object
var bindObject = require('bind-object')
var object = {
foo: function () {
return this.bar
},
bar: 'baz'
}
bindObject(object)
var foo = object.foo
foo() // => 'baz'
Binds the functions in an object to the object itself and ignores other values. Returns the original object for convenience.
Required
Type: object
The object to bind.
MIT © Ben Drucker