Hyperlinkv0.8.0-beta.28

Sink

Sink.takeUntilEffectconsteffect/Sink.ts:1737
<In, E, R>(predicate: (input: In) => Effect.Effect<boolean, E, R>): Sink<
  Array<In>,
  In,
  In,
  E,
  R
>

Collects input elements effectfully until the predicate returns true, including the matching element in the result.

Details

If the predicate effect fails, the sink fails with the same error.

constructors
Source effect/Sink.ts:173715 lines
export const takeUntilEffect = <In, E, R>(
  predicate: (input: In) => Effect.Effect<boolean, E, R>
): Sink<Array<In>, In, In, E, R> =>
  suspend(() => {
    let done = false
    return takeWhileEffect((input) => {
      if (done) {
        return Effect.succeed(false)
      }
      return Effect.map(predicate(input), (b) => {
        done = b
        return true
      })
    })
  })