feat(facade): add ListWrapper.flatten
This commit is contained in:
parent
91999e016e
commit
a1880c3576
|
@ -232,6 +232,14 @@ class ListWrapper {
|
||||||
static bool isImmutable(List l) {
|
static bool isImmutable(List l) {
|
||||||
return l is UnmodifiableListView;
|
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;
|
bool isListLikeIterable(obj) => obj is Iterable;
|
||||||
|
|
|
@ -278,6 +278,11 @@ export class ListWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static isImmutable(list: any[]): boolean { return Object.isSealed(list); }
|
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 {
|
export function isListLikeIterable(obj: any): boolean {
|
||||||
|
|
Loading…
Reference in New Issue