Hyperlinkv0.8.0-beta.28

Chunk

Chunk.appendconsteffect/Chunk.ts:695
<A2>(a: A2): <A>(self: Chunk<A>) => NonEmptyChunk<A2 | A>
<A, A2>(self: Chunk<A>, a: A2): NonEmptyChunk<A | A2>

Appends the specified element to the end of the Chunk.

When to use

Use to add one element after the existing chunk elements and return a NonEmptyChunk.

Example (Appending an element)

import { Chunk } from "effect"

const chunk = Chunk.make(1, 2, 3)
const newChunk = Chunk.append(chunk, 4)
console.log(Chunk.toArray(newChunk)) // [1, 2, 3, 4]

// Appending to empty chunk
const emptyChunk = Chunk.empty<number>()
const singleElement = Chunk.append(emptyChunk, 42)
console.log(Chunk.toArray(singleElement)) // [42]
Source effect/Chunk.ts:6954 lines
export const append: {
  <A2>(a: A2): <A>(self: Chunk<A>) => NonEmptyChunk<A2 | A>
  <A, A2>(self: Chunk<A>, a: A2): NonEmptyChunk<A | A2>
} = dual(2, <A, A2>(self: Chunk<A>, a: A2): NonEmptyChunk<A | A2> => appendAll(self, of(a)))
Referenced by 2 symbols