Hyperlinkv0.8.0-beta.28

Sink

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

Runs an effectful function for each non-empty input array 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:185511 lines
export const forEachWhileArray = <In, E, R>(
  f: (input: NonEmptyReadonlyArray<In>) => Effect.Effect<boolean, E, R>
): Sink<void, In, never, E, R> =>
  fromTransform((upstream) =>
    upstream.pipe(
      Effect.flatMap(f),
      Effect.flatMap((cont) => cont ? Effect.void : Cause.done()),
      Effect.forever({ disableYield: true }),
      Pull.catchDone(() => endVoid)
    )
  )
Referenced by 1 symbols