feat(ivy): support deep queries through view boundaries (#21700)

PR Close #21700
This commit is contained in:
Pawel Kozlowski
2018-01-17 17:55:55 +01:00
committed by Misko Hevery
parent 3e03dbe576
commit 5269ce287e
9 changed files with 519 additions and 82 deletions

View File

@ -31,3 +31,28 @@ export function stringify(value: any): string {
export function notImplemented(): Error {
return new Error('NotImplemented');
}
/**
* Flattens an array in non-recursive way. Input arrays are not modified.
*/
export function flatten(list: any[]): any[] {
const result: any[] = [];
let i = 0;
while (i < list.length) {
const item = list[i];
if (Array.isArray(item)) {
if (item.length > 0) {
list = item.concat(list.slice(i + 1));
i = 0;
} else {
i++;
}
} else {
result.push(item);
i++;
}
}
return result;
}