Skip to content
PACKAGES

onFirstData()

onFirstData (alias tapFirst): invoke fn exactly once on the first qualifying value (default where: v => v != null — null/undefined pass through without counting as “first”), then pass all values through unchanged. The one-shot guard is per-node ctx.state (NOT a factory closure, so a second instantiation of the same factory re-arms — R-ctx-state).

import { onFirstData } from "@graphrefly/ts/operators";
function onFirstData(
fn: (v: S) => void,
opts?: { where?: (v: S) => boolean },
): Operator<S, S>
ParameterTypeDescription
fn(v: S) => voidSynchronous function invoked by the helper.
opts{ where?: (v: S) => boolean }Options that configure the helper.

A Operator<S, S> value.

import { onFirstData } from "@graphrefly/ts/operators";

packages/ts/src/graph/operators.ts