Socket
Book a DemoInstallSign in
Socket

object-delegate

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-delegate

Delegate methods to a target object's context

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

delegate

FAQs

Package last updated on 08 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts