argos/dmp-frontend/src/app/utilities/enhancers/flatJoinOn.ts

10 lines
230 B
TypeScript

interface Array<T> {
flatJoinOn<E, J>(by: (item: T) => J): Array<E>;
}
Array.prototype.flatJoinOn = function (f: Function) {
return this.groupBy(f).reduce((ys: any, x: any) => {
return ys.concat(f.call(this, x));
}, []);
};