feat(facade): add ListWrapper.flatten

This commit is contained in:
vsavkin 2016-03-23 13:42:19 -07:00 committed by Victor Savkin
parent 91999e016e
commit a1880c3576
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -278,6 +278,11 @@ export class ListWrapper {
}
static isImmutable(list: any[]): boolean { return Object.isSealed(list); }
static flatten<T>(array: T[][]): T[] {
let res = [];
array.forEach((a) => res = res.concat(a));
return res;
}
}
export function isListLikeIterable(obj: any): boolean {