Hyperlinkv0.8.0-beta.28

TxChunk

TxChunk.appendconsteffect/TxChunk.ts:401
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void>
<A>(self: TxChunk<A>, element: A): Effect.Effect<void>

Appends an element to the end of the TxChunk.

Details

This function mutates the original TxChunk by adding the element to the end. It does not return a new TxChunk reference.

Example (Appending an element)

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

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

  // Add element to the end atomically
  yield* TxChunk.append(txChunk, 4)

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