From a1880c3576392a3ba18466bc9b5a7a67b2ffbd2f Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 23 Mar 2016 13:42:19 -0700 Subject: [PATCH] feat(facade): add ListWrapper.flatten --- modules/angular2/src/facade/collection.dart | 8 ++++++++ modules/angular2/src/facade/collection.ts | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/modules/angular2/src/facade/collection.dart b/modules/angular2/src/facade/collection.dart index b903e584f2..5768c09af1 100644 --- a/modules/angular2/src/facade/collection.dart +++ b/modules/angular2/src/facade/collection.dart @@ -232,6 +232,14 @@ class ListWrapper { static bool isImmutable(List l) { return l is UnmodifiableListView; } + + static List flatten(List l) { + final res = []; + l.forEach((item) { + res.addAll(item); + }); + return res; + } } bool isListLikeIterable(obj) => obj is Iterable; diff --git a/modules/angular2/src/facade/collection.ts b/modules/angular2/src/facade/collection.ts index ef6587492c..636bd4657d 100644 --- a/modules/angular2/src/facade/collection.ts +++ b/modules/angular2/src/facade/collection.ts @@ -278,6 +278,11 @@ export class ListWrapper { } static isImmutable(list: any[]): boolean { return Object.isSealed(list); } + static flatten(array: T[][]): T[] { + let res = []; + array.forEach((a) => res = res.concat(a)); + return res; + } } export function isListLikeIterable(obj: any): boolean {