refactor(router): improve flatten fn

closes #15505
This commit is contained in:
Dzmitry Shylovich 2017-03-26 17:36:44 +03:00 committed by Victor Berchet
parent 606b8fafb0
commit 8e03f65645
1 changed files with 2 additions and 8 deletions

View File

@ -41,14 +41,8 @@ export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): bool
return true;
}
export function flatten<T>(a: T[][]): T[] {
const target: T[] = [];
for (let i = 0; i < a.length; ++i) {
for (let j = 0; j < a[i].length; ++j) {
target.push(a[i][j]);
}
}
return target;
export function flatten<T>(arr: T[][]): T[] {
return Array.prototype.concat.apply([], arr);
}
export function first<T>(a: T[]): T {