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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i object-delegate

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • yoshuawuyts