augment-with

0.0.2 • Public • Published

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);
});

Readme

Keywords

Package Sidebar

Install

npm i augment-with

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • webreflection