/** * Accumulates incoming elements into a chunk as long as they verify predicate * `p`. * * @tsplus static effect/core/stream/Sink.Ops collectAllWhile */ export function collectAllWhile( p: Predicate ): Sink> { return Sink.fold, boolean]>( [List.empty(), true as boolean] as const, (tuple) => tuple[1], ([as, _], a) => (p(a) ? [as.prepend(a), true] as const : [as, false] as const) ).map(([inputs, _]) => Chunk.from(inputs.reverse)) }