deepFilter

Function

Traverse a graph filtering out entries that do not pass the predicate

Note: this util uses cloning behind the scenes so will only work for POJOs and not class instances

example: const predicate = (link: any) => link.key !== "00a" const obj = [ { key: "001", label: "Stop the Spotted Lanternfly", }, { key: "002", label: "Create a Map", children: [ { key: "00a", label: "ArcGIS Map Viewer", }, { key: "00b", label: "ArcGIS Map Viewer Classic", }, ], }, ]; const res = deepFilter(obj, predicate) res = [ { key: "001", label: "Stop the Spotted Lanternfly", }, { key: "002", label: "Create a Map", children: [ { key: "00b", label: "ArcGIS Map Viewer Classic", }, ], }, ];

  • deepFilter(object: any, predicate: function(object: any) : boolean) : any

Parameters

Parameter Type Default Notes
object Required any
predicate Required function(object: any) : boolean

Returns

any

Function defined in common/src/objects/deepFilter.ts:54