filter.nodes.predicate
predicate(fn: NodePredicateFn, options?: { on?: Scope; invert?: boolean; id?: string }): FilterHandlePredicate (escape-hatch) filter on nodes.
The supplied function receives each NodeData and returns true to keep the node visible, false to hide it. Use this for any logic that cannot be expressed via range, dateRange, or match — cross-property computations, derived values, custom string parsing, etc.
Notes:
includeNullis intentionally absent — the predicate sees raw data and decides null-handling itself.- The predicate is invoked on every visibility recomputation. Keep it pure and cheap.
fn | (node: NodeData) => boolean | Pure predicate. Return true to keep, false to hide. |
options.on | string | string[] | '*' | Restrict to a subset of node categories. Default: '*' (all). |
options.invert | boolean | Invert pass/fail. Default: false. |
options.id | string | Override the auto-generated handle id. |
Returns: FilterHandle
Example
// Composite check: keep Persons whose age >= 18 AND whose name starts with "A"
const composite = api.filter.nodes.predicate(
(node) => {
const age = node.properties.age;
const name = node.properties.name;
return typeof age === "number" && age >= 18
&& typeof name === "string" && name.startsWith("A");
},
{ on: "Person" }
);