object-delegate
Delegate methods to a target object's context. Does not return a new object.
Pretty similar to delegate
but without the specific namespaces.
Installation
npm install object-delegate
Usage
var delegate = require('object-delegate');
var obj = {};
delegate(obj)
.method('foo', function foo() {})
.method('something', function bar() {})
.method('okBaz', function baz() {});
API
delegate(obj)
Set the target of the delegation. Returns its own context to allow method chaining.
var myObj = {
foo: function() {
console.log('cats are soft');
}
}
delegate(myObj);
.method(namespace, fn)
Delegate a method to the object
delegate({})
.method('foo', function foo() {})
.method('cat', function cat() {})
.method('dog', function dog() {});