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

Function flatten

modules/core/src/utils/flatten.ts:17–27  ·  view source on GitHub ↗
(
  array: T | NestedArray<T>,
  filter: (element: T) => boolean = () => true
)

Source from the content-addressed store, hash-verified

15 * @return Returns the new flattened array (new array or `result` if provided)
16 */
17export function flatten<T>(
18 array: T | NestedArray<T>,
19 filter: (element: T) => boolean = () => true
20): T[] {
21 // Wrap single object in array
22 if (!Array.isArray(array)) {
23 return filter(array) ? [array] : [];
24 }
25 // Deep flatten and filter the array
26 return flattenArray(array, filter, []);
27}
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[] {

Callers 7

_postUpdateFunction · 0.90
setLayersMethod · 0.90
_setViewsMethod · 0.90
flatten.spec.tsFile · 0.90
resolveLayerGroupsFunction · 0.85
afterRenderFunction · 0.85
renderLayersMethod · 0.85

Calls 1

flattenArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…