MCPcopy
hub / github.com/visgl/deck.gl / flattenArray

Function flattenArray

modules/core/src/utils/flatten.ts:30–41  ·  view source on GitHub ↗

Deep flattens an array. Helper to `flatten`, see its parameters

(array: NestedArray<T>, filter: (element: T) => boolean, result: T[])

Source from the content-addressed store, hash-verified

28
29/** Deep flattens an array. Helper to `flatten`, see its parameters */
30function flattenArray<T>(array: NestedArray<T>, filter: (element: T) => boolean, result: T[]): T[] {
31 let index = -1;
32 while (++index < array.length) {
33 const value = array[index];
34 if (Array.isArray(value)) {
35 flattenArray(value, filter, result);
36 } else if (filter(value)) {
37 result.push(value);
38 }
39 }
40 return result;
41}
42
43/** Uses copyWithin to significantly speed up typed array value filling */
44export function fillArray({target, source, start = 0, count = 1}) {

Callers 1

flattenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…