Skip to content

Commit

Permalink
refactor(router): improve flatten fn
Browse files Browse the repository at this point in the history
  • Loading branch information
DzmitryShylovich authored and vicb committed Mar 28, 2017
1 parent 606b8fa commit 8e03f65
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/router/src/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8e03f65

Please sign in to comment.