import type { ChunkBuilder } from "@tsplus/stdlib/collections/Chunk" /** * A sink that collects first `n` elements into a chunk. * * @tsplus static effect/core/stream/Sink.Ops collectAllN */ export function collectAllN(n: number): Sink> { return Sink.fromEffect(Effect.sync(Chunk.builder())) .flatMap((cb) => Sink.foldUntil>(cb, n, (builder, input) => builder.append(input)) ) .map((builder) => builder.build()) }