@effect-ts/system
Version:
Effect-TS is a zero dependency set of libraries to write highly productive, purely functional TypeScript at scale.
28 lines (24 loc) • 885 B
text/typescript
// ets_tracing: off
import type * as T from "../../../../Effect/index.js"
import * as SK from "../../Sink/index.js"
import type * as C from "../core.js"
import * as Run from "./run.js"
/**
* Consumes elements of the stream, passing them to the specified callback,
* and terminating consumption when the callback returns `false`.
*/
export function runForEachWhile_<R, R1, E, E1, A>(
self: C.Stream<R, E, A>,
f: (a: A) => T.Effect<R1, E1, boolean>
): T.Effect<R & R1, E | E1, void> {
return Run.run_(self, SK.forEachWhile(f))
}
/**
* Consumes elements of the stream, passing them to the specified callback,
* and terminating consumption when the callback returns `false`.
*
* @ets_data_first runForEachWhile_
*/
export function runForEachWhile<R1, E1, A>(f: (a: A) => T.Effect<R1, E1, boolean>) {
return <R, E>(self: C.Stream<R, E, A>) => runForEachWhile_(self, f)
}