effect-io-ai

Package: effect
Module: TxChunk

TxChunk.slice

Takes a slice of the TxChunk from start to end (exclusive).

Details

This function mutates the original TxChunk by keeping only the elements in the specified range. It does not return a new TxChunk reference.

Example (Taking a slice)

import { Chunk, Effect, TxChunk } from "effect"

const program = Effect.gen(function*() {
  const txChunk = yield* TxChunk.fromIterable([1, 2, 3, 4, 5, 6, 7])

  // Take elements from index 2 to 5 (exclusive) - automatically transactional
  yield* TxChunk.slice(txChunk, 2, 5)

  const result = yield* TxChunk.get(txChunk)
  console.log(Chunk.toReadonlyArray(result)) // [3, 4, 5]
})

Signature

declare const slice: { (start: number, end: number): <A>(self: TxChunk<A>) => Effect.Effect<void>; <A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void>; }

Source

Since v4.0.0