UNPKG

cheetah-framework

Version:

Cheetah Framework JS used in all our applications

25 lines (18 loc) 581 B
const arrayFunction = { push (...data) { return Object.getPrototypeOf(this).push.call(this, ..._.map(data, this.modifier)) }, unshift (...data) { return Object.getPrototypeOf(this).unshift.call(this, ..._.map(data, this.modifier)) }, splice (start, end, ...data) { return Object.getPrototypeOf(this).splice.call(this, start, end, ..._.map(data, this.modifier)) } } class ArrayMutator extends Array { constructor (data, modifier) { super(..._.map(data, modifier)) _.assign(this, { modifier }, arrayFunction) } } export default ArrayMutator