export class Collection extends Map { constructor() { super(); Object.defineProperty(this, '_array', { value: null, writable: true, configurable: true }); Object.defineProperty(this, '_keyArray', { value: null, writable: true, configurable: true }); } toArray () { return [...this.values()]; } forEach (...args) { // @ts-ignore return this.toArray().forEach(...args); } filter (...args) { // @ts-ignore return this.toArray().filter(...args); } find (...args) { // @ts-ignore return this.toArray().find(...args); } map (...args) { // @ts-ignore return this.toArray().map(...args); } reduce (...args) { // @ts-ignore return this.toArray().reduce(...args); } pluck (key) { return this.toArray().reduce((i, o) => { if (!o[key]) return i; i.push(o[key]); return i; }); } groupBy (key) { return this.toArray().reduce((i, o) => { const val = o[key]; i[val] = i[val] || []; i[val].push(o); return i; }); } unique () { return [...new Set(this.toArray())]; } }