npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

object-delegate

1.0.0

@yoshuawuyts

npmHomeRepoSnykSocket
Downloads:0
$ npm install object-delegate
DailyWeeklyMonthlyYearly

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