effect-io-ai

Package: effect
Module: Stream

Stream.dropRight

Drops the last specified number of elements from this stream.

Details

Keeps the last n elements in memory to drop them on completion.

Example (Dropping values from the right)

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

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

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

Signature

declare const dropRight: { (n: number): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>; <A, E, R>(self: Stream<A, E, R>, n: number): Stream<A, E, R>; }

Source

Since v2.0.0