Hyperlinkv0.8.0-beta.28

Stream

Stream.chunksconsteffect/Stream.ts:6998
<A, E, R>(self: Stream<A, E, R>): Stream<
  Arr.NonEmptyReadonlyArray<A>,
  E,
  R
>

Exposes the underlying chunks as a stream of non-empty arrays.

Example (Exposing stream chunks)

import { Console, Effect, Stream } from "effect"

const program = Effect.gen(function*() {
  const chunks = yield* Stream.make(1, 2, 3, 4).pipe(
    Stream.rechunk(2),
    Stream.chunks,
    Stream.runCollect
  )
  yield* Console.log(chunks)
})

Effect.runPromise(program)
// Output: [ [ 1, 2 ], [ 3, 4 ] ]
grouping
Source effect/Stream.ts:69985 lines
export const chunks = <A, E, R>(self: Stream<A, E, R>): Stream<Arr.NonEmptyReadonlyArray<A>, E, R> =>
  self.channel.pipe(
    Channel.map(Arr.of),
    fromChannel
  )
Referenced by 1 symbols