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

10 lines
220 B
TypeScript
Raw Normal View History

interface Array<T> {
flatMap<E>(callback: (t: T) => Array<E>): Array<E>;
}
Array.prototype.flatMap = function (f: Function) {
return this.reduce((ys: any, x: any) => {
return ys.concat(f.call(this, x));
}, []);
};