Hyperlinkv0.8.0-beta.28

Stream

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

Flattens a stream of non-empty arrays into a stream of elements.

Example (Flattening a stream of non-empty arrays into a stream of elements)

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

const stream = Stream.make(Array.make(1, 2), Array.make(3))

const program = Effect.gen(function* () {
  const result = yield* Stream.runCollect(Stream.flattenArray(stream))
  yield* Console.log(result)
})

Effect.runPromise(program)
// Output: [ 1, 2, 3 ]
sequencing
Source effect/Stream.ts:26012 lines
export const flattenArray = <A, E, R>(self: Stream<Arr.NonEmptyReadonlyArray<A>, E, R>): Stream<A, E, R> =>
  fromChannel(Channel.flattenArray(self.channel))