Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

object-delegate

1.0.0 • Public • Published

object-delegate

NPM version build status Test coverage Downloads

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() {});

License

MIT

install

npm i object-delegate

Downloadsweekly downloads

3

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar