delega

0.1.1 • Public • Published

Synopsis

Concise creation of delegate methods for your classes/objects

NPM

Build Status Coverage Status

browser support

Usage

For objects

var objA = {
  foo: function() {
    return "a";
  },
  foo2:  function() {
    return "b";
  }
};
 
var objB = {};
delega.delegateToObject(objB, objA, ['foo','foo2']);
 
expect(objB.foo()).to.be.equal("a");
expect(objB.foo2()).to.be.equal("b");

For classes

var objA = {
  foo: function() {
    return "a";
  },
  foo2: function() {
    return "b";
  }
};
 
var clazzB = function() {
  this.a = objA;
};
 
delega.delegateToProperty(objB, 'a', ['foo', 'foo2']);
 
expect(new clazzB().foo()).to.be.equal("a");
expect(new clazzB().foo2()).to.be.equal("b");

Bitdeli Badge

Readme

Keywords

Package Sidebar

Install

npm i delega

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • mariocasciaro