Skip to content

Instantly share code, notes, and snippets.

@nicolasbrugneaux
Created July 2, 2015 15:47
Show Gist options
  • Save nicolasbrugneaux/2e6bec20d955d1b676d3 to your computer and use it in GitHub Desktop.
Save nicolasbrugneaux/2e6bec20d955d1b676d3 to your computer and use it in GitHub Desktop.
export default class Collection
{
constructor( { collection=[], shouldUpdateBeforeRender=false, shouldUpdateAfterRender=false } )
{
this._collection = collection;
this._shouldUpdateBeforeRender = shouldUpdateBeforeRender;
this._shouldUpdateAfterRender = shouldUpdateAfterRender;
}
// blah blah custom methods
}
Object.getOwnPropertyNames( Array.prototype ).forEach( prop =>
{
const method = Array.prototype[prop];
if ( typeof method === 'function' && prop !== 'constructor' )
{
var descriptor = {
key: prop,
value()
{
return this._collection[prop]( ...arguments );
}
};
Object.defineProperty( Collection.prototype, prop, descriptor );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment