Hyperlinkv0.8.0-beta.28

Sink

Sink.forEachWhileconsteffect/Sink.ts:1832
<In, E, R>(f: (input: In) => Effect.Effect<boolean, E, R>): Sink<
  void,
  In,
  never,
  E,
  R
>

Runs an effectful function for each input element while it returns true.

Details

The sink stops consuming input when the function returns false or when the upstream stream ends, and completes with void.

constructors
Source effect/Sink.ts:183210 lines
export const forEachWhile = <In, E, R>(
  f: (input: In) => Effect.Effect<boolean, E, R>
): Sink<void, In, never, E, R> =>
  forEachWhileArray(Effect.fnUntraced(function*(input) {
    for (let i = 0; i < input.length; i++) {
      const cont = yield* f(input[i])
      if (!cont) return false
    }
    return true
  }))