Hyperlinkv0.8.0-beta.28

TxChunk

TxChunk.dropconsteffect/TxChunk.ts:588
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
<A>(self: TxChunk<A>, n: number): Effect.Effect<void>

Drops the first n elements from the TxChunk.

Details

This function mutates the original TxChunk by removing the first n elements. It does not return a new TxChunk reference.

Example (Dropping leading elements)

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

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

  // Drop the first 2 elements - automatically transactional
  yield* TxChunk.drop(txChunk, 2)

  const result = yield* TxChunk.get(txChunk)
  console.log(Chunk.toReadonlyArray(result)) // [3, 4, 5]
})
combinators
Source effect/TxChunk.ts:5887 lines
export const drop: {
  (n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
  <A>(self: TxChunk<A>, n: number): Effect.Effect<void>
} = dual(
  2,
  <A>(self: TxChunk<A>, n: number): Effect.Effect<void> => update(self, (current) => Chunk.drop(current, n))
)
Referenced by 5 symbols