API Reference
map()
Transform each upstream DATA value with a synchronous mapping function.
Import
import { map } from "@graphrefly/ts/operators";
Signature
function map(fn: ((v: S) => T) | Definition<S, T>): Operator<S, T>
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | ((v: S) => T) | Definition<S, T> | Mapping function, or a named define() definition for checkpoint restoration. |
Returns
An operator that emits fn(value) for each upstream value.
Example
import { graph } from "@graphrefly/ts/graph";
import { map } from "@graphrefly/ts/operators";
const g = graph();
const count = g.state(1);
const doubled = g.initNode(map((value: number) => value * 2), [count]);
Remarks
- Restorable maps: Passing a named
define()registers semantic restore metadata.
Source
packages/ts/src/graph/operators.ts