Created
July 2, 2015 15:47
-
-
Save nicolasbrugneaux/2e6bec20d955d1b676d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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