Hyperlinkv0.8.0-beta.28

TxChunk

TxChunk.prependAllconsteffect/TxChunk.ts:771
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>

Concatenates another chunk to the beginning of the TxChunk.

Details

This function mutates the original TxChunk by prepending all elements from the other chunk. It does not return a new TxChunk reference.

Example (Prepending another chunk)

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

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

  // Prepend all elements from another chunk atomically
  yield* TxChunk.prependAll(txChunk, otherChunk)

  const result = yield* TxChunk.get(txChunk)
  console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4, 5, 6]
})
combinators
Source effect/TxChunk.ts:7718 lines
export const prependAll: {
  <A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
  <A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>
} = dual(
  2,
  <A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void> =>
    update(self, (current) => Chunk.prependAll(current, other))
)