Expand description
Flow operators (Slice C-3, D024) — count / predicate / terminal-aware
gates that bound which DATA reaches the downstream output.
Mirrors the TS shapes in
~/src/graphrefly-ts/packages/pure-ts/src/extra/operators/take.ts,
driven by Core dispatch (graphrefly_core::OperatorOp::Take /
[Skip] / [TakeWhile] / [Last]) instead of derived-fn factories.
take— emits the firstcountDATA values then self-completes.count == 0is allowed (D027): self-completes on first fire with noData.skip— drops the firstcountDATA values; emits the rest.take_while— emits whilepredicateholds; on firstfalse, emits any preceding passes then self-completes.last/last_with_default— buffers the latestDATA; emitsData(latest)(orData(default)if no DATA arrived and a default was registered) thenCompleteon upstream COMPLETE.first— sugar fortake(source, 1).find— sugar fortake(filter(source, predicate), 1).element_at— sugar fortake(skip(source, index), 1).
take_until(source, notifier) is intentionally NOT in this slice —
it requires the producer / subscription-managed pattern (D020
category B), out of scope for the Core-dispatch operator family.
§Refcount discipline
For last_with_default, the default handle ownership transfers
from the caller’s binding-side intern into Core’s
LastState via a retain
taken inside register_operator. The caller is expected to retain a
share for themselves if they want to reference the default
elsewhere.
Structs§
- Flow
Registration - Registration output for flow operators that don’t carry a user
closure (
take,skip,last,last_with_default). Zero FFI on the fire path; only thenodeid matters.
Functions§
- element_
at element_at(source, index)— emits theindexth DATA (zero-based) thenComplete. Sugar fortake(skip(source, index), 1).- find
find(source, predicate)— emits the first DATA matchingpredicatethenComplete. Sugar fortake(filter(source, predicate), 1).- first
first(source)— emits the first DATA thenComplete. Sugar fortake(source, 1).- last
last(source)— buffers the latest DATA; emitsData(latest)thenCompleteon upstream COMPLETE. On empty stream (no DATA arrived), emits onlyComplete— subscribers see[Start, Complete]. For a fallback value on empty streams, uselast_with_default.- last_
with lastwith explicitOperatorOpts.- last_
with_ default last_with_default(source, default)— buffers the latest DATA; emitsData(latest)thenCompleteon upstream COMPLETE. On empty stream (no DATA arrived), emitsData(default)thenComplete.- last_
with_ default_ with last_with_defaultwith explicitOperatorOpts.- skip
skip(source, count)— drops the firstcountDATA values; once the threshold is crossed, subsequent DATAs pass through verbatim. On a wave where every input is still in the skip window, settles[Dirty, Resolved](D018 pattern).- skip_
with skipwith explicitOperatorOpts.- take
take(source, count)— emits the firstcountDATA values then self-completes viaCore::complete. When upstream completes beforecountis reached, the standard auto-cascade propagates COMPLETE.- take_
while take_while(source, predicate)— emits whilepredicate(input)holds; on the firstfalse, emits any preceding passes from the same batch then self-completes. ReusesBindingBoundary::predicate_each(D029).- take_
while_ with take_whilewith explicitOperatorOpts.- take_
with takewith explicitOperatorOpts.