Skip to content

WebReflection/augment-with

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

augment-with

basic utility to augment a constructor

how

var augmentWith = require('augment-with');
var augmentWithArray = require('augment-with-array');


var Collection = augmentWith(
  augmentWithArray,
  function Collection(array) {
    this.push.apply(this, array);
  }
);

Collection.prototype.each = funcion each(fn) {
  this.forEach(function (value, i, self) {
    fn.call(this, i, value);
  }, this);
};

new Collection(['a', 'b', 'c']).each(function (i, value) {
  console.log(i, value);
});

About

basic utility to augment a constructor

Resources

Stars

Watchers

Forks

Packages

No packages published