effect-io-ai

Package: effect
Module: Stream

Stream.range

Constructs a stream from a range of integers, including both endpoints.

Details

If the provided min is greater than max, the stream will not emit any values.

Example (Creating a numeric range)

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

const program = Effect.gen(function*() {
  const values = yield* Stream.range(1, 5).pipe(Stream.runCollect)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ 1, 2, 3, 4, 5 ]

Signature

declare const range: (min: number, max: number, chunkSize?: number) => Stream<number>

Source

Since v2.0.0