filternodes

filter.nodes.predicate

predicate(fn: NodePredicateFn, options?: { on?: Scope; invert?: boolean; id?: string }): FilterHandle

Predicate (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:

  • includeNull is 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) => booleanPure predicate. Return true to keep, false to hide.
options.on string | string[] | '*'Restrict to a subset of node categories. Default: '*' (all).
options.invert booleanInvert pass/fail. Default: false.
options.id stringOverride 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" }
);