From 8e03f65645c1fadbb1be0bfee7c358979e73b0b8 Mon Sep 17 00:00:00 2001 From: Dzmitry Shylovich Date: Sun, 26 Mar 2017 17:36:44 +0300 Subject: [PATCH] refactor(router): improve flatten fn closes #15505 --- packages/router/src/utils/collection.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/router/src/utils/collection.ts b/packages/router/src/utils/collection.ts index 6384ed49b3..bde4fe70a8 100644 --- a/packages/router/src/utils/collection.ts +++ b/packages/router/src/utils/collection.ts @@ -41,14 +41,8 @@ export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): bool return true; } -export function flatten(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(arr: T[][]): T[] { + return Array.prototype.concat.apply([], arr); } export function first(a: T[]): T {