API Reference
filter()
Pass through upstream values that satisfy a predicate.
Import
import { filter } from "@graphrefly/ts/operators";
Signature
function filter(pred: (v: S) => boolean): Operator<S, S>
Parameters
| Parameter | Type | Description |
|---|---|---|
pred | (v: S) => boolean | Predicate evaluated for each upstream DATA value. |
Returns
An operator that emits matching values and stays quiet for non-matches.
Example
import { graph } from "@graphrefly/ts/graph";
import { filter } from "@graphrefly/ts/operators";
const g = graph();
const count = g.state(0);
const even = g.initNode(filter((value: number) => value % 2 === 0), [count]);
Source
packages/ts/src/graph/operators.ts