<A>(self: NonEmptyChunk<A>): Chunk<A>Returns every element after the first from a non-empty chunk.
Example (Getting the tail of a non-empty chunk)
import { Chunk } from "effect"
const nonEmptyChunk = Chunk.make(1, 2, 3, 4)
const result = Chunk.tailNonEmpty(nonEmptyChunk)
console.log(Chunk.toArray(result)) // [2, 3, 4]
const singleElement = Chunk.make(1)
const resultSingle = Chunk.tailNonEmpty(singleElement)
console.log(Chunk.toArray(resultSingle)) // []
// Type safety: this function only accepts NonEmptyChunk
// Chunk.tailNonEmpty(Chunk.empty()) // TypeScript errorelements
Source effect/Chunk.ts:21301 lines
export const const tailNonEmpty: <A>(
self: NonEmptyChunk<A>
) => Chunk<A>
Returns every element after the first from a non-empty chunk.
Example (Getting the tail of a non-empty chunk)
import { Chunk } from "effect"
const nonEmptyChunk = Chunk.make(1, 2, 3, 4)
const result = Chunk.tailNonEmpty(nonEmptyChunk)
console.log(Chunk.toArray(result)) // [2, 3, 4]
const singleElement = Chunk.make(1)
const resultSingle = Chunk.tailNonEmpty(singleElement)
console.log(Chunk.toArray(resultSingle)) // []
// Type safety: this function only accepts NonEmptyChunk
// Chunk.tailNonEmpty(Chunk.empty()) // TypeScript error
tailNonEmpty = <function (type parameter) A in <A>(self: NonEmptyChunk<A>): Chunk<A>A>(self: NonEmptyChunk<A>(parameter) self: {
length: number;
right: Chunk<A>;
left: Chunk<A>;
backing: Backing<A>;
depth: number;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface NonEmptyChunk<out A>A non-empty Chunk guaranteed to contain at least one element.
Example (Working with non-empty chunks)
import { Chunk } from "effect"
const nonEmptyChunk: Chunk.NonEmptyChunk<number> = Chunk.make(1, 2, 3)
console.log(Chunk.headNonEmpty(nonEmptyChunk)) // 1
console.log(Chunk.lastNonEmpty(nonEmptyChunk)) // 3
NonEmptyChunk<function (type parameter) A in <A>(self: NonEmptyChunk<A>): Chunk<A>A>): interface Chunk<out A>A Chunk is an immutable, ordered collection optimized for efficient concatenation and access patterns.
Example (Inspecting chunk values)
import { Chunk } from "effect"
const chunk: Chunk.Chunk<number> = Chunk.make(1, 2, 3)
console.log(chunk.length) // 3
console.log(Chunk.toArray(chunk)) // [1, 2, 3]
A namespace containing utility types for Chunk operations.
Example (Working with Chunk utility types)
import type { Chunk } from "effect"
// Extract the element type from a Chunk
declare const chunk: Chunk.Chunk<string>
type ElementType = Chunk.Chunk.Infer<typeof chunk> // string
// Create a preserving non-emptiness
declare const nonEmptyChunk: Chunk.NonEmptyChunk<number>
type WithString = Chunk.Chunk.With<typeof nonEmptyChunk, string> // Chunk.NonEmptyChunk<string>
Chunk<function (type parameter) A in <A>(self: NonEmptyChunk<A>): Chunk<A>A> => const drop: {
(n: number): <A>(self: Chunk<A>) => Chunk<A>
<A>(self: Chunk<A>, n: number): Chunk<A>
}
drop(self: NonEmptyChunk<A>(parameter) self: {
length: number;
right: Chunk<A>;
left: Chunk<A>;
backing: Backing<A>;
depth: number;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, 1)