diff --git "a/.opencode/node_modules/effect/dist/Chunk.d.ts" "b/.opencode/node_modules/effect/dist/Chunk.d.ts" --- "a/.opencode/node_modules/effect/dist/Chunk.d.ts" +++ "b/.opencode/node_modules/effect/dist/Chunk.d.ts" @@ -1,70 +1,11 @@ /** - * The `Chunk` module provides an immutable, high-performance sequence data structure - * optimized for functional programming patterns. A `Chunk` is a persistent data structure - * that supports efficient append, prepend, and concatenation operations. + * Stores many values in an immutable ordered collection. * - * ## What is a Chunk? - * - * A `Chunk` is an immutable sequence of elements of type `A` that provides: - * - **O(1) append and prepend operations** - * - **Efficient concatenation** through tree-like structure - * - **Memory efficiency** with structural sharing - * - **Rich API** with functional programming operations - * - **Type safety** with full TypeScript integration - * - * ## Key Features - * - * - **Immutable**: All operations return new chunks without modifying the original - * - **Efficient**: Optimized data structure with logarithmic complexity for most operations - * - **Functional**: Rich set of transformation and combination operators - * - **Lazy evaluation**: Many operations are deferred until needed - * - **Interoperable**: Easy conversion to/from arrays and other collections - * - * ## Performance Characteristics - * - * - **Append/Prepend**: O(1) amortized - * - **Random Access**: O(log n) - * - **Concatenation**: O(log min(m, n)) - * - **Iteration**: O(n) - * - **Memory**: Structural sharing minimizes allocation - * - * @example - * ```ts - * import { Chunk } from "effect" - * - * // Creating chunks - * const chunk1 = Chunk.fromIterable([1, 2, 3]) - * const chunk2 = Chunk.fromIterable([4, 5, 6]) - * const empty = Chunk.empty() - * - * // Combining chunks - * const combined = Chunk.appendAll(chunk1, chunk2) - * console.log(Chunk.toReadonlyArray(combined)) // [1, 2, 3, 4, 5, 6] - * ``` - * - * @example - * ```ts - * import { Chunk } from "effect" - * - * // Functional transformations - * const numbers = Chunk.range(1, 5) // [1, 2, 3, 4, 5] - * const doubled = Chunk.map(numbers, (n) => n * 2) // [2, 4, 6, 8, 10] - * const evens = Chunk.filter(doubled, (n) => n % 4 === 0) // [4, 8] - * const sum = Chunk.reduce(evens, 0, (acc, n) => acc + n) // 12 - * ``` - * - * @example - * ```ts - * import { Chunk, Effect } from "effect" - * - * // Working with Effects - * const processChunk = (chunk: Chunk.Chunk) => - * Effect.gen(function*() { - * const mapped = Chunk.map(chunk, (n) => n * 2) - * const filtered = Chunk.filter(mapped, (n) => n > 5) - * return Chunk.toReadonlyArray(filtered) - * }) - * ``` + * A `Chunk` is useful when you need to build or transform collections + * without changing the original collection. It is designed for efficient + * append, prepend, and concatenation. This module includes helpers for + * creating, reading, slicing, mapping, filtering, sorting, zipping, combining, + * and converting chunks to and from arrays and iterables. * * @since 2.0.0 */ @@ -87,7 +28,8 @@ declare const TypeId = "~effect/collections/Chunk"; /** * A Chunk is an immutable, ordered collection optimized for efficient concatenation and access patterns. * - * @example + * **Example** (Inspecting chunk values) + * * ```ts * import { Chunk } from "effect" * @@ -112,7 +54,8 @@ export interface Chunk extends Iterable, Equal.Equal, Pipeable, Inspec /** * A non-empty Chunk guaranteed to contain at least one element. * - * @example + * **Example** (Working with non-empty chunks) + * * ```ts * import { Chunk } from "effect" * @@ -129,13 +72,13 @@ export interface NonEmptyChunk extends Chunk, NonEmptyIterable { /** * Type lambda for Chunk, used for higher-kinded type operations. * - * @example + * **Example** (Applying the Chunk type lambda) + * * ```ts - * import type { ChunkTypeLambda } from "effect/Chunk" - * import type { Kind } from "effect/HKT" + * import type { Chunk, HKT } from "effect" * * // Create a Chunk type using the type lambda - * type NumberChunk = Kind + * type NumberChunk = HKT.Kind * // Equivalent to: Chunk * ``` * @@ -169,12 +112,13 @@ interface ISlice { readonly length: number; } /** - * Compares the two chunks of equal length using the specified function + * Creates an `Equivalence` for chunks that compares chunk lengths and then + * compares corresponding elements with the provided element equivalence. + * + * **Example** (Comparing chunks for equivalence) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Equivalence from "effect/Equivalence" + * import { Chunk, Equivalence } from "effect" * * const chunk1 = Chunk.make(1, 2, 3) * const chunk2 = Chunk.make(1, 2, 3) @@ -185,14 +129,15 @@ interface ISlice { * console.log(eq(chunk1, chunk3)) // false * ``` * - * @category equivalence - * @since 2.0.0 + * @category instances + * @since 4.0.0 */ export declare const makeEquivalence: (isEquivalent: Equivalence.Equivalence) => Equivalence.Equivalence>; /** - * Checks if `u` is a `Chunk` + * Checks whether `u` is a `Chunk` + * + * **Example** (Checking for chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -209,9 +154,10 @@ export declare const makeEquivalence: (isEquivalent: Equivalence.Equivalence< */ export declare const isChunk: { /** - * Checks if `u` is a `Chunk` + * Checks whether `u` is a `Chunk` + * + * **Example** (Checking for chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -228,9 +174,10 @@ export declare const isChunk: { */ (u: Iterable): u is Chunk; /** - * Checks if `u` is a `Chunk` + * Checks whether `u` is a `Chunk` + * + * **Example** (Checking for chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -250,7 +197,8 @@ export declare const isChunk: { /** * Creates an empty `Chunk`. * - * @example + * **Example** (Creating an empty chunk) + * * ```ts * import { Chunk } from "effect" * @@ -265,13 +213,13 @@ export declare const empty: () => Chunk; /** * Builds a `NonEmptyChunk` from an non-empty collection of elements. * - * @example + * **Example** (Creating a non-empty chunk) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 1, 2, 3, 4 ] } + * console.log(Chunk.toArray(chunk)) // [1, 2, 3, 4] * ``` * * @category constructors @@ -281,13 +229,13 @@ export declare const make: ]>(...as: As) /** * Builds a `NonEmptyChunk` from a single element. * - * @example + * **Example** (Creating a single-element chunk) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.of("hello") - * console.log(chunk) - * // { _id: 'Chunk', values: [ "hello" ] } + * console.log(Chunk.toArray(chunk)) // ["hello"] * ``` * * @category constructors @@ -297,13 +245,13 @@ export declare const of: (a: A) => NonEmptyChunk; /** * Creates a new `Chunk` from an iterable collection of values. * - * @example + * **Example** (Creating chunks from iterables) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.fromIterable([1, 2, 3]) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(chunk)) // [1, 2, 3] * ``` * * @category constructors @@ -315,7 +263,8 @@ export declare const fromIterable: (self: Iterable) => Chunk; * (`NonEmptyChunk`), the function will return a `NonEmptyArray`, ensuring the * non-empty property is preserved. * - * @example + * **Example** (Converting chunks to mutable arrays) + * * ```ts * import { Chunk } from "effect" * @@ -329,7 +278,7 @@ export declare const fromIterable: (self: Iterable) => Chunk; * console.log(Chunk.toArray(emptyChunk)) // [] * ``` * - * @category conversions + * @category converting * @since 2.0.0 */ export declare const toArray: >(self: S) => S extends NonEmptyChunk ? RA.NonEmptyArray> : Array>; @@ -338,7 +287,8 @@ export declare const toArray: >(self: S) => S extends NonEm * non-empty (`NonEmptyChunk`), the function will return a * `NonEmptyReadonlyArray`, ensuring the non-empty property is preserved. * - * @example + * **Example** (Converting chunks to readonly arrays) + * * ```ts * import { Chunk } from "effect" * @@ -354,15 +304,23 @@ export declare const toArray: >(self: S) => S extends NonEm * console.log(Chunk.toReadonlyArray(emptyChunk)) // [] * ``` * - * @category conversions + * @category converting * @since 2.0.0 */ export declare const toReadonlyArray: >(self: S) => S extends NonEmptyChunk ? RA.NonEmptyReadonlyArray> : ReadonlyArray>; /** * Reverses the order of elements in a `Chunk`. - * Importantly, if the input chunk is a `NonEmptyChunk`, the reversed chunk will also be a `NonEmptyChunk`. * - * @example + * **When to use** + * + * Use to read or process chunk elements in reverse order. + * + * **Details** + * + * If the input chunk is a `NonEmptyChunk`, the reversed chunk is also a + * `NonEmptyChunk`. + * + * **Example** (Reversing chunks) * * ```ts * import { Chunk } from "effect" @@ -370,18 +328,19 @@ export declare const toReadonlyArray: >(self: S) => S exten * const chunk = Chunk.make(1, 2, 3) * const result = Chunk.reverse(chunk) * - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 2, 1 ] } + * console.log(Chunk.toArray(result)) // [3, 2, 1] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const reverse: >(self: S) => Chunk.With>; /** - * This function provides a safe way to read a value at a particular index from a `Chunk`. + * Gets the value at an index in a `Chunk` safely, returning `None` when the index is + * out of bounds. + * + * **Example** (Accessing elements safely) * - * @example * ```ts * import { Chunk } from "effect" * @@ -401,9 +360,11 @@ export declare const reverse: >(self: S) => Chunk.With(self: Chunk) => Option; /** - * This function provides a safe way to read a value at a particular index from a `Chunk`. + * Gets the value at an index in a `Chunk` safely, returning `None` when the index is + * out of bounds. + * + * **Example** (Accessing elements safely) * - * @example * ```ts * import { Chunk } from "effect" * @@ -446,9 +409,19 @@ export declare const get: { (self: Chunk, index: number): Option; }; /** - * Wraps an array into a chunk without copying, unsafe on mutable arrays + * Wraps an array into a chunk without copying. + * + * **When to use** + * + * Use when the input array can be shared with the resulting `Chunk` and avoiding + * a copy matters. + * + * **Gotchas** + * + * Mutating the source array after wrapping can mutate the resulting `Chunk`. + * + * **Example** (Creating chunks without copying arrays) * - * @example * ```ts * import { Chunk } from "effect" * @@ -461,17 +434,26 @@ export declare const get: { * console.log(Chunk.toArray(chunk)) // [999, 2, 3, 4, 5] * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const fromArrayUnsafe: (self: ReadonlyArray) => Chunk; /** - * Wraps an array into a chunk without copying, unsafe on mutable arrays + * Wraps a non-empty array into a non-empty chunk without copying. + * + * **When to use** + * + * Use when the input array is already known to be non-empty, can be shared with + * the resulting `Chunk`, and avoiding a copy matters. + * + * **Gotchas** + * + * Mutating the source array after wrapping can mutate the resulting `Chunk`. + * + * **Example** (Creating non-empty chunks without copying arrays) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Array from "effect/Array" + * import { Array, Chunk } from "effect" * * const nonEmptyArray = Array.make(1, 2, 3, 4, 5) * const chunk = Chunk.fromNonEmptyArrayUnsafe(nonEmptyArray) @@ -481,87 +463,111 @@ export declare const fromArrayUnsafe: (self: ReadonlyArray) => Chunk; * console.log(Chunk.isNonEmpty(chunk)) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const fromNonEmptyArrayUnsafe: (self: NonEmptyReadonlyArray) => NonEmptyChunk; /** - * Gets an element unsafely, will throw on out of bounds + * Gets an element at the specified index without returning an `Option`. + * + * **When to use** + * + * Use when reading from a `Chunk` at an index known to be in bounds and direct + * element access is preferred over handling `Option.none`. + * + * **Gotchas** + * + * Throws if the index is out of bounds. + * + * **Example** (Accessing elements unsafely) * - * @example * ```ts - * import { Chunk } from "effect" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * * console.log(Chunk.getUnsafe(chunk, 1)) // "b" * console.log(Chunk.getUnsafe(chunk, 3)) // "d" * - * // Warning: This will throw an error for invalid indices - * try { - * Chunk.getUnsafe(chunk, 10) // throws "Index out of bounds" - * } catch (error) { - * console.log((error as Error).message) // "Index out of bounds" - * } + * // Use Chunk.get when the index may be out of bounds + * console.log(Option.isNone(Chunk.get(chunk, 10))) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const getUnsafe: { /** - * Gets an element unsafely, will throw on out of bounds + * Gets an element at the specified index without returning an `Option`. + * + * **When to use** + * + * Use when reading from a `Chunk` at an index known to be in bounds and direct + * element access is preferred over handling `Option.none`. + * + * **Gotchas** + * + * Throws if the index is out of bounds. + * + * **Example** (Accessing elements unsafely) * - * @example * ```ts - * import { Chunk } from "effect" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * * console.log(Chunk.getUnsafe(chunk, 1)) // "b" * console.log(Chunk.getUnsafe(chunk, 3)) // "d" * - * // Warning: This will throw an error for invalid indices - * try { - * Chunk.getUnsafe(chunk, 10) // throws "Index out of bounds" - * } catch (error) { - * console.log((error as Error).message) // "Index out of bounds" - * } + * // Use Chunk.get when the index may be out of bounds + * console.log(Option.isNone(Chunk.get(chunk, 10))) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ (index: number): (self: Chunk) => A; /** - * Gets an element unsafely, will throw on out of bounds + * Gets an element at the specified index without returning an `Option`. + * + * **When to use** + * + * Use when reading from a `Chunk` at an index known to be in bounds and direct + * element access is preferred over handling `Option.none`. + * + * **Gotchas** + * + * Throws if the index is out of bounds. + * + * **Example** (Accessing elements unsafely) * - * @example * ```ts - * import { Chunk } from "effect" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * * console.log(Chunk.getUnsafe(chunk, 1)) // "b" * console.log(Chunk.getUnsafe(chunk, 3)) // "d" * - * // Warning: This will throw an error for invalid indices - * try { - * Chunk.getUnsafe(chunk, 10) // throws "Index out of bounds" - * } catch (error) { - * console.log((error as Error).message) // "Index out of bounds" - * } + * // Use Chunk.get when the index may be out of bounds + * console.log(Option.isNone(Chunk.get(chunk, 10))) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ (self: Chunk, index: number): A; }; /** * Appends the specified element to the end of the `Chunk`. * - * @example + * **When to use** + * + * Use to add one element after the existing chunk elements and return a + * `NonEmptyChunk`. + * + * **Example** (Appending an element) + * * ```ts * import { Chunk } from "effect" * @@ -575,14 +581,23 @@ export declare const getUnsafe: { * console.log(Chunk.toArray(singleElement)) // [42] * ``` * - * @category concatenating + * @see {@link prepend} for adding one element before the existing elements + * @see {@link appendAll} for appending all elements from another chunk + * + * @category combining * @since 2.0.0 */ export declare const append: { /** * Appends the specified element to the end of the `Chunk`. * - * @example + * **When to use** + * + * Use to add one element after the existing chunk elements and return a + * `NonEmptyChunk`. + * + * **Example** (Appending an element) + * * ```ts * import { Chunk } from "effect" * @@ -596,14 +611,23 @@ export declare const append: { * console.log(Chunk.toArray(singleElement)) // [42] * ``` * - * @category concatenating + * @see {@link prepend} for adding one element before the existing elements + * @see {@link appendAll} for appending all elements from another chunk + * + * @category combining * @since 2.0.0 */ (a: A2): (self: Chunk) => NonEmptyChunk; /** * Appends the specified element to the end of the `Chunk`. * - * @example + * **When to use** + * + * Use to add one element after the existing chunk elements and return a + * `NonEmptyChunk`. + * + * **Example** (Appending an element) + * * ```ts * import { Chunk } from "effect" * @@ -617,15 +641,19 @@ export declare const append: { * console.log(Chunk.toArray(singleElement)) // [42] * ``` * - * @category concatenating + * @see {@link prepend} for adding one element before the existing elements + * @see {@link appendAll} for appending all elements from another chunk + * + * @category combining * @since 2.0.0 */ (self: Chunk, a: A2): NonEmptyChunk; }; /** - * Prepend an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * Prepends an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * + * **Example** (Prepending an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -639,14 +667,15 @@ export declare const append: { * console.log(Chunk.toArray(singleElement)) // ["first"] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const prepend: { /** - * Prepend an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * Prepends an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * + * **Example** (Prepending an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -660,14 +689,15 @@ export declare const prepend: { * console.log(Chunk.toArray(singleElement)) // ["first"] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ (elem: B): (self: Chunk) => NonEmptyChunk; /** - * Prepend an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * Prepends an element to the front of a `Chunk`, creating a new `NonEmptyChunk`. + * + * **Example** (Prepending an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -681,7 +711,7 @@ export declare const prepend: { * console.log(Chunk.toArray(singleElement)) // ["first"] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Chunk, elem: B): NonEmptyChunk; @@ -689,14 +719,14 @@ export declare const prepend: { /** * Takes the first up to `n` elements from the chunk. * - * @example + * **Example** (Taking elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.take(chunk, 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -706,14 +736,14 @@ export declare const take: { /** * Takes the first up to `n` elements from the chunk. * - * @example + * **Example** (Taking elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.take(chunk, 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -723,14 +753,14 @@ export declare const take: { /** * Takes the first up to `n` elements from the chunk. * - * @example + * **Example** (Taking elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.take(chunk, 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -741,14 +771,14 @@ export declare const take: { /** * Drops the first up to `n` elements from the chunk. * - * @example + * **Example** (Dropping elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.drop(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -758,14 +788,14 @@ export declare const drop: { /** * Drops the first up to `n` elements from the chunk. * - * @example + * **Example** (Dropping elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.drop(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -775,14 +805,14 @@ export declare const drop: { /** * Drops the first up to `n` elements from the chunk. * - * @example + * **Example** (Dropping elements from the start) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.drop(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -793,14 +823,14 @@ export declare const drop: { /** * Drops the last `n` elements. * - * @example + * **Example** (Dropping elements from the end) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropRight(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -810,14 +840,14 @@ export declare const dropRight: { /** * Drops the last `n` elements. * - * @example + * **Example** (Dropping elements from the end) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropRight(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -827,14 +857,14 @@ export declare const dropRight: { /** * Drops the last `n` elements. * - * @example + * **Example** (Dropping elements from the end) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropRight(chunk, 2) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 2, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 2, 3] * ``` * * @category elements @@ -845,14 +875,14 @@ export declare const dropRight: { /** * Drops all elements so long as the predicate returns true. * - * @example + * **Example** (Dropping elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropWhile(chunk, (n) => n < 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -862,14 +892,14 @@ export declare const dropWhile: { /** * Drops all elements so long as the predicate returns true. * - * @example + * **Example** (Dropping elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropWhile(chunk, (n) => n < 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -879,14 +909,14 @@ export declare const dropWhile: { /** * Drops all elements so long as the predicate returns true. * - * @example + * **Example** (Dropping elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropWhile(chunk, (n) => n < 3) - * console.log(result) - * // { _id: 'Chunk', values: [ 3, 4, 5 ] } + * console.log(Chunk.toArray(result)) // [3, 4, 5] * ``` * * @category elements @@ -898,7 +928,7 @@ export declare const dropWhile: { * Prepends the specified prefix chunk to the beginning of the specified chunk. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **Example** (Prepending all elements) * * ```ts * import { Chunk } from "effect" @@ -912,7 +942,7 @@ export declare const dropWhile: { * // [ "a", "b", 1, 2 ] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const prependAll: { @@ -920,7 +950,7 @@ export declare const prependAll: { * Prepends the specified prefix chunk to the beginning of the specified chunk. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **Example** (Prepending all elements) * * ```ts * import { Chunk } from "effect" @@ -934,7 +964,7 @@ export declare const prependAll: { * // [ "a", "b", 1, 2 ] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ , T extends Chunk>(that: T): (self: S) => Chunk.OrNonEmpty | Chunk.Infer>; @@ -942,7 +972,7 @@ export declare const prependAll: { * Prepends the specified prefix chunk to the beginning of the specified chunk. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **Example** (Prepending all elements) * * ```ts * import { Chunk } from "effect" @@ -956,7 +986,7 @@ export declare const prependAll: { * // [ "a", "b", 1, 2 ] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Chunk, that: NonEmptyChunk): NonEmptyChunk; @@ -964,7 +994,7 @@ export declare const prependAll: { * Prepends the specified prefix chunk to the beginning of the specified chunk. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **Example** (Prepending all elements) * * ```ts * import { Chunk } from "effect" @@ -978,7 +1008,7 @@ export declare const prependAll: { * // [ "a", "b", 1, 2 ] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: NonEmptyChunk, that: Chunk): NonEmptyChunk; @@ -986,7 +1016,7 @@ export declare const prependAll: { * Prepends the specified prefix chunk to the beginning of the specified chunk. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **Example** (Prepending all elements) * * ```ts * import { Chunk } from "effect" @@ -1000,7 +1030,7 @@ export declare const prependAll: { * // [ "a", "b", 1, 2 ] * ``` * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Chunk, that: Chunk): Chunk; @@ -1009,7 +1039,12 @@ export declare const prependAll: { * Concatenates two chunks, combining their elements. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **When to use** + * + * Use to concatenate two chunks when the second chunk's elements should come + * after the first. + * + * **Example** (Appending all elements) * * ```ts * import { Chunk } from "effect" @@ -1023,7 +1058,10 @@ export declare const prependAll: { * // [ 1, 2, "a", "b" ] * ``` * - * @category concatenating + * @see {@link prependAll} for concatenating chunks in the opposite order + * @see {@link append} for adding a single element to the end + * + * @category combining * @since 2.0.0 */ export declare const appendAll: { @@ -1031,7 +1069,12 @@ export declare const appendAll: { * Concatenates two chunks, combining their elements. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **When to use** + * + * Use to concatenate two chunks when the second chunk's elements should come + * after the first. + * + * **Example** (Appending all elements) * * ```ts * import { Chunk } from "effect" @@ -1045,7 +1088,10 @@ export declare const appendAll: { * // [ 1, 2, "a", "b" ] * ``` * - * @category concatenating + * @see {@link prependAll} for concatenating chunks in the opposite order + * @see {@link append} for adding a single element to the end + * + * @category combining * @since 2.0.0 */ , T extends Chunk>(that: T): (self: S) => Chunk.OrNonEmpty | Chunk.Infer>; @@ -1053,7 +1099,12 @@ export declare const appendAll: { * Concatenates two chunks, combining their elements. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **When to use** + * + * Use to concatenate two chunks when the second chunk's elements should come + * after the first. + * + * **Example** (Appending all elements) * * ```ts * import { Chunk } from "effect" @@ -1067,7 +1118,10 @@ export declare const appendAll: { * // [ 1, 2, "a", "b" ] * ``` * - * @category concatenating + * @see {@link prependAll} for concatenating chunks in the opposite order + * @see {@link append} for adding a single element to the end + * + * @category combining * @since 2.0.0 */ (self: Chunk, that: NonEmptyChunk): NonEmptyChunk; @@ -1075,7 +1129,12 @@ export declare const appendAll: { * Concatenates two chunks, combining their elements. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **When to use** + * + * Use to concatenate two chunks when the second chunk's elements should come + * after the first. + * + * **Example** (Appending all elements) * * ```ts * import { Chunk } from "effect" @@ -1089,7 +1148,10 @@ export declare const appendAll: { * // [ 1, 2, "a", "b" ] * ``` * - * @category concatenating + * @see {@link prependAll} for concatenating chunks in the opposite order + * @see {@link append} for adding a single element to the end + * + * @category combining * @since 2.0.0 */ (self: NonEmptyChunk, that: Chunk): NonEmptyChunk; @@ -1097,7 +1159,12 @@ export declare const appendAll: { * Concatenates two chunks, combining their elements. * If either chunk is non-empty, the result is also a non-empty chunk. * - * @example + * **When to use** + * + * Use to concatenate two chunks when the second chunk's elements should come + * after the first. + * + * **Example** (Appending all elements) * * ```ts * import { Chunk } from "effect" @@ -1111,7 +1178,10 @@ export declare const appendAll: { * // [ 1, 2, "a", "b" ] * ``` * - * @category concatenating + * @see {@link prependAll} for concatenating chunks in the opposite order + * @see {@link append} for adding a single element to the end + * + * @category combining * @since 2.0.0 */ (self: Chunk, that: Chunk): Chunk; @@ -1119,10 +1189,10 @@ export declare const appendAll: { /** * Returns a filtered and mapped subset of the elements. * - * @example + * **Example** (Filtering and mapping values) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "world") * const numbers = Chunk.filterMap(chunk, (str) => { @@ -1139,17 +1209,17 @@ export declare const appendAll: { * console.log(Chunk.toArray(evenIndexNumbers)) // [1] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ export declare const filterMap: { /** * Returns a filtered and mapped subset of the elements. * - * @example + * **Example** (Filtering and mapping values) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "world") * const numbers = Chunk.filterMap(chunk, (str) => { @@ -1166,17 +1236,17 @@ export declare const filterMap: { * console.log(Chunk.toArray(evenIndexNumbers)) // [1] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (f: (input: A, i: number) => Result): (self: Chunk) => Chunk; /** * Returns a filtered and mapped subset of the elements. * - * @example + * **Example** (Filtering and mapping values) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "world") * const numbers = Chunk.filterMap(chunk, (str) => { @@ -1193,15 +1263,16 @@ export declare const filterMap: { * console.log(Chunk.toArray(evenIndexNumbers)) // [1] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (self: Chunk, f: (input: A, i: number) => Result): Chunk; }; /** * Returns a filtered subset of the elements. * - * @example + * **Example** (Filtering values) + * * ```ts * import { Chunk } from "effect" * @@ -1215,14 +1286,15 @@ export declare const filterMap: { * console.log(Chunk.toArray(numbers)) // [42, 100] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ export declare const filter: { /** * Returns a filtered subset of the elements. * - * @example + * **Example** (Filtering values) + * * ```ts * import { Chunk } from "effect" * @@ -1236,14 +1308,15 @@ export declare const filter: { * console.log(Chunk.toArray(numbers)) // [42, 100] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (refinement: Refinement, B>): (self: Chunk) => Chunk; /** * Returns a filtered subset of the elements. * - * @example + * **Example** (Filtering values) + * * ```ts * import { Chunk } from "effect" * @@ -1257,14 +1330,15 @@ export declare const filter: { * console.log(Chunk.toArray(numbers)) // [42, 100] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (predicate: Predicate>): (self: Chunk) => Chunk; /** * Returns a filtered subset of the elements. * - * @example + * **Example** (Filtering values) + * * ```ts * import { Chunk } from "effect" * @@ -1278,14 +1352,15 @@ export declare const filter: { * console.log(Chunk.toArray(numbers)) // [42, 100] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (self: Chunk, refinement: Refinement): Chunk; /** * Returns a filtered subset of the elements. * - * @example + * **Example** (Filtering values) + * * ```ts * import { Chunk } from "effect" * @@ -1299,18 +1374,18 @@ export declare const filter: { * console.log(Chunk.toArray(numbers)) // [42, 100] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (self: Chunk, predicate: Predicate): Chunk; }; /** * Transforms all elements of the chunk for as long as the specified function succeeds. * - * @example + * **Example** (Filtering and mapping while values match) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "4") * const result = Chunk.filterMapWhile(chunk, (s) => { @@ -1328,17 +1403,17 @@ export declare const filter: { * console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ export declare const filterMapWhile: { /** * Transforms all elements of the chunk for as long as the specified function succeeds. * - * @example + * **Example** (Filtering and mapping while values match) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "4") * const result = Chunk.filterMapWhile(chunk, (s) => { @@ -1356,17 +1431,17 @@ export declare const filterMapWhile: { * console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (f: Filter.Filter): (self: Chunk) => Chunk; /** * Transforms all elements of the chunk for as long as the specified function succeeds. * - * @example + * **Example** (Filtering and mapping while values match) + * * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make("1", "2", "hello", "3", "4") * const result = Chunk.filterMapWhile(chunk, (s) => { @@ -1384,23 +1459,22 @@ export declare const filterMapWhile: { * console.log(Chunk.toArray(allNumbers)) // [1, 2, 3, 4] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ (self: Chunk, f: Filter.Filter): Chunk; }; /** - * Filter out optional values + * Filters out optional values + * + * **Example** (Compacting optional values) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(Option.some(1), Option.none(), Option.some(3)) * const result = Chunk.compact(chunk) - * console.log(result) - * // { _id: 'Chunk', values: [ 1, 3 ] } + * console.log(Chunk.toArray(result)) // [1, 3] * ``` * * @category filtering @@ -1410,7 +1484,8 @@ export declare const compact: (self: Chunk>) => Chunk; /** * Applies a function to each element in a chunk and returns a new chunk containing the concatenated mapped elements. * - * @example + * **Example** (Flat mapping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1431,14 +1506,15 @@ export declare const compact: (self: Chunk>) => Chunk; * console.log(Chunk.toArray(indexed)) // [1, 3, 5] * ``` * - * @since 2.0.0 * @category sequencing + * @since 2.0.0 */ export declare const flatMap: { /** * Applies a function to each element in a chunk and returns a new chunk containing the concatenated mapped elements. * - * @example + * **Example** (Flat mapping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1459,14 +1535,15 @@ export declare const flatMap: { * console.log(Chunk.toArray(indexed)) // [1, 3, 5] * ``` * - * @since 2.0.0 * @category sequencing + * @since 2.0.0 */ , T extends Chunk>(f: (a: Chunk.Infer, i: number) => T): (self: S) => Chunk.AndNonEmpty>; /** * Applies a function to each element in a chunk and returns a new chunk containing the concatenated mapped elements. * - * @example + * **Example** (Flat mapping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1487,14 +1564,15 @@ export declare const flatMap: { * console.log(Chunk.toArray(indexed)) // [1, 3, 5] * ``` * - * @since 2.0.0 * @category sequencing + * @since 2.0.0 */ (self: NonEmptyChunk, f: (a: A, i: number) => NonEmptyChunk): NonEmptyChunk; /** * Applies a function to each element in a chunk and returns a new chunk containing the concatenated mapped elements. * - * @example + * **Example** (Flat mapping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1515,8 +1593,8 @@ export declare const flatMap: { * console.log(Chunk.toArray(indexed)) // [1, 3, 5] * ``` * - * @since 2.0.0 * @category sequencing + * @since 2.0.0 */ (self: Chunk, f: (a: A, i: number) => Chunk): Chunk; }; @@ -1530,7 +1608,8 @@ export declare const flatMap: { * instead, it is primarily used for side effects, such as logging or * accumulating data in an external variable. * - * @example + * **Example** (Iterating over chunk values) + * * ```ts * import { Chunk } from "effect" * @@ -1553,8 +1632,8 @@ export declare const flatMap: { * // Index 3: 4 * ``` * - * @since 2.0.0 * @category combinators + * @since 2.0.0 */ export declare const forEach: { /** @@ -1567,7 +1646,8 @@ export declare const forEach: { * instead, it is primarily used for side effects, such as logging or * accumulating data in an external variable. * - * @example + * **Example** (Iterating over chunk values) + * * ```ts * import { Chunk } from "effect" * @@ -1590,8 +1670,8 @@ export declare const forEach: { * // Index 3: 4 * ``` * - * @since 2.0.0 * @category combinators + * @since 2.0.0 */ (f: (a: A, index: number) => B): (self: Chunk) => void; /** @@ -1604,7 +1684,8 @@ export declare const forEach: { * instead, it is primarily used for side effects, such as logging or * accumulating data in an external variable. * - * @example + * **Example** (Iterating over chunk values) + * * ```ts * import { Chunk } from "effect" * @@ -1627,15 +1708,16 @@ export declare const forEach: { * // Index 3: 4 * ``` * - * @since 2.0.0 * @category combinators + * @since 2.0.0 */ (self: Chunk, f: (a: A, index: number) => B): void; }; /** * Flattens a chunk of chunks into a single chunk by concatenating all chunks. * - * @example + * **Example** (Flattening nested chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1656,14 +1738,29 @@ export declare const forEach: { * console.log(Chunk.toArray(Chunk.flatten(withEmpty))) // [1, 2, 3, 4] * ``` * - * @since 2.0.0 * @category sequencing + * @since 2.0.0 */ export declare const flatten: >>(self: S) => Chunk.Flatten; /** * Groups elements in chunks of up to `n` elements. * - * @example + * **When to use** + * + * Use to divide a chunk into ordered, non-overlapping chunks with at most `n` + * elements each. + * + * **Details** + * + * The final chunk may contain fewer than `n` elements. Empty input produces an + * empty chunk of chunks. + * + * **Gotchas** + * + * Values of `n` less than or equal to zero produce singleton chunks. + * + * **Example** (Splitting into fixed-size chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1680,14 +1777,31 @@ export declare const flatten: >>(self: S) => Chunk.Fl * // [[1, 2], [3, 4], [5]] * ``` * - * @since 2.0.0 + * @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size + * * @category elements + * @since 2.0.0 */ export declare const chunksOf: { /** * Groups elements in chunks of up to `n` elements. * - * @example + * **When to use** + * + * Use to divide a chunk into ordered, non-overlapping chunks with at most `n` + * elements each. + * + * **Details** + * + * The final chunk may contain fewer than `n` elements. Empty input produces an + * empty chunk of chunks. + * + * **Gotchas** + * + * Values of `n` less than or equal to zero produce singleton chunks. + * + * **Example** (Splitting into fixed-size chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1704,14 +1818,31 @@ export declare const chunksOf: { * // [[1, 2], [3, 4], [5]] * ``` * - * @since 2.0.0 + * @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size + * * @category elements + * @since 2.0.0 */ (n: number): (self: Chunk) => Chunk>; /** * Groups elements in chunks of up to `n` elements. * - * @example + * **When to use** + * + * Use to divide a chunk into ordered, non-overlapping chunks with at most `n` + * elements each. + * + * **Details** + * + * The final chunk may contain fewer than `n` elements. Empty input produces an + * empty chunk of chunks. + * + * **Gotchas** + * + * Values of `n` less than or equal to zero produce singleton chunks. + * + * **Example** (Splitting into fixed-size chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1728,17 +1859,22 @@ export declare const chunksOf: { * // [[1, 2], [3, 4], [5]] * ``` * - * @since 2.0.0 + * @see {@link split} for splitting into a target number of chunks instead of a fixed chunk size + * * @category elements + * @since 2.0.0 */ (self: Chunk, n: number): Chunk>; }; /** - * Creates a Chunk of unique values that are included in all given Chunks. + * Creates a `Chunk` of values that are included in both chunks. * - * The order and references of result values are determined by the Chunk. + * **Details** + * + * The order and references of result values are determined by the first chunk. + * + * **Example** (Intersecting chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -1758,16 +1894,19 @@ export declare const chunksOf: { * console.log(Chunk.toArray(Chunk.intersection(chunk3, chunk4))) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const intersection: { /** - * Creates a Chunk of unique values that are included in all given Chunks. + * Creates a `Chunk` of values that are included in both chunks. * - * The order and references of result values are determined by the Chunk. + * **Details** + * + * The order and references of result values are determined by the first chunk. + * + * **Example** (Intersecting chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -1787,16 +1926,19 @@ export declare const intersection: { * console.log(Chunk.toArray(Chunk.intersection(chunk3, chunk4))) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (that: Chunk): (self: Chunk) => Chunk; /** - * Creates a Chunk of unique values that are included in all given Chunks. + * Creates a `Chunk` of values that are included in both chunks. + * + * **Details** * - * The order and references of result values are determined by the Chunk. + * The order and references of result values are determined by the first chunk. + * + * **Example** (Intersecting chunks) * - * @example * ```ts * import { Chunk } from "effect" * @@ -1816,15 +1958,16 @@ export declare const intersection: { * console.log(Chunk.toArray(Chunk.intersection(chunk3, chunk4))) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Chunk, that: Chunk): Chunk; }; /** * Determines if the chunk is empty. * - * @example + * **Example** (Checking for empty chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1839,7 +1982,8 @@ export declare const isEmpty: (self: Chunk) => boolean; /** * Determines if the chunk is not empty. * - * @example + * **Example** (Checking for non-empty chunks) + * * ```ts * import { Chunk } from "effect" * @@ -1852,9 +1996,10 @@ export declare const isEmpty: (self: Chunk) => boolean; */ export declare const isNonEmpty: (self: Chunk) => self is NonEmptyChunk; /** - * Returns the first element of this chunk if it exists. + * Returns the first element of this chunk safely if it exists. + * + * **Example** (Getting the first element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -1869,11 +2014,19 @@ export declare const head: (self: Chunk) => Option; /** * Returns the first element of this chunk. * - * It will throw an error if the chunk is empty. + * **When to use** + * + * Use when you know the chunk is non-empty and need the first element directly + * without handling `Option.none`. + * + * **Gotchas** + * + * Throws an error if the chunk is empty. + * + * **Example** (Getting the first element unsafely) * - * @example * ```ts - * import { Chunk } from "effect" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.headUnsafe(chunk)) // 1 @@ -1881,22 +2034,19 @@ export declare const head: (self: Chunk) => Option; * const singleElement = Chunk.make("hello") * console.log(Chunk.headUnsafe(singleElement)) // "hello" * - * // Warning: This will throw for empty chunks - * try { - * Chunk.headUnsafe(Chunk.empty()) - * } catch (error) { - * console.log((error as Error).message) // "Index out of bounds" - * } + * // Use Chunk.head when the chunk may be empty + * console.log(Option.isNone(Chunk.head(Chunk.empty()))) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const headUnsafe: (self: Chunk) => A; /** * Returns the first element of this non empty chunk. * - * @example + * **Example** (Getting the first element of a non-empty chunk) + * * ```ts * import { Chunk } from "effect" * @@ -1910,14 +2060,15 @@ export declare const headUnsafe: (self: Chunk) => A; * // Chunk.headNonEmpty(Chunk.empty()) // TypeScript error * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const headNonEmpty: (self: NonEmptyChunk) => A; /** - * Returns the last element of this chunk if it exists. + * Returns the last element of this chunk safely if it exists. + * + * **Example** (Getting the last element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -1932,11 +2083,19 @@ export declare const last: (self: Chunk) => Option; /** * Returns the last element of this chunk. * - * It will throw an error if the chunk is empty. + * **When to use** + * + * Use when you know the chunk is non-empty and need the last element directly + * without handling `Option.none`. + * + * **Gotchas** + * + * Throws an error if the chunk is empty. + * + * **Example** (Getting the last element unsafely) * - * @example * ```ts - * import { Chunk } from "effect" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.lastUnsafe(chunk)) // 4 @@ -1944,22 +2103,19 @@ export declare const last: (self: Chunk) => Option; * const singleElement = Chunk.make("hello") * console.log(Chunk.lastUnsafe(singleElement)) // "hello" * - * // Warning: This will throw for empty chunks - * try { - * Chunk.lastUnsafe(Chunk.empty()) - * } catch (error) { - * console.log((error as Error).message) // "Index out of bounds" - * } + * // Use Chunk.last when the chunk may be empty + * console.log(Option.isNone(Chunk.last(Chunk.empty()))) // true * ``` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const lastUnsafe: (self: Chunk) => A; /** * Returns the last element of this non empty chunk. * - * @example + * **Example** (Getting the last element of a non-empty chunk) + * * ```ts * import { Chunk } from "effect" * @@ -1973,14 +2129,15 @@ export declare const lastUnsafe: (self: Chunk) => A; * // Chunk.lastNonEmpty(Chunk.empty()) // TypeScript error * ``` * - * @since 3.4.0 * @category elements + * @since 3.4.0 */ export declare const lastNonEmpty: (self: NonEmptyChunk) => A; /** * A namespace containing utility types for Chunk operations. * - * @example + * **Example** (Working with Chunk utility types) + * * ```ts * import type { Chunk } from "effect" * @@ -1993,14 +2150,14 @@ export declare const lastNonEmpty: (self: NonEmptyChunk) => A; * type WithString = Chunk.Chunk.With // Chunk.NonEmptyChunk * ``` * - * @category types * @since 2.0.0 */ export declare namespace Chunk { /** * Infers the element type of a Chunk. * - * @example + * **Example** (Inferring element types) + * * ```ts * import type { Chunk } from "effect" * @@ -2018,7 +2175,8 @@ export declare namespace Chunk { /** * Constructs a Chunk type preserving non-emptiness. * - * @example + * **Example** (Preserving non-emptiness) + * * ```ts * import type { Chunk } from "effect" * @@ -2036,7 +2194,8 @@ export declare namespace Chunk { /** * Creates a non-empty Chunk if either input is non-empty. * - * @example + * **Example** (Preserving non-emptiness from either input) + * * ```ts * import type { Chunk } from "effect" * @@ -2067,7 +2226,8 @@ export declare namespace Chunk { /** * Creates a non-empty Chunk only if both inputs are non-empty. * - * @example + * **Example** (Requiring non-emptiness from both inputs) + * * ```ts * import type { Chunk } from "effect" * @@ -2098,7 +2258,8 @@ export declare namespace Chunk { /** * Flattens a nested Chunk type. * - * @example + * **Example** (Flattening nested chunk types) + * * ```ts * import type { Chunk } from "effect" * @@ -2118,83 +2279,80 @@ export declare namespace Chunk { * Transforms the elements of a chunk using the specified mapping function. * If the input chunk is non-empty, the resulting chunk will also be non-empty. * - * @example + * **Example** (Mapping values) * * ```ts * import { Chunk } from "effect" * * const result = Chunk.map(Chunk.make(1, 2), (n) => n + 1) * - * console.log(result) - * // { _id: 'Chunk', values: [ 2, 3 ] } + * console.log(Chunk.toArray(result)) // [2, 3] * ``` * - * @since 2.0.0 * @category mapping + * @since 2.0.0 */ export declare const map: { /** * Transforms the elements of a chunk using the specified mapping function. * If the input chunk is non-empty, the resulting chunk will also be non-empty. * - * @example + * **Example** (Mapping values) * * ```ts * import { Chunk } from "effect" * * const result = Chunk.map(Chunk.make(1, 2), (n) => n + 1) * - * console.log(result) - * // { _id: 'Chunk', values: [ 2, 3 ] } + * console.log(Chunk.toArray(result)) // [2, 3] * ``` * - * @since 2.0.0 * @category mapping + * @since 2.0.0 */ , B>(f: (a: Chunk.Infer, i: number) => B): (self: S) => Chunk.With; /** * Transforms the elements of a chunk using the specified mapping function. * If the input chunk is non-empty, the resulting chunk will also be non-empty. * - * @example + * **Example** (Mapping values) * * ```ts * import { Chunk } from "effect" * * const result = Chunk.map(Chunk.make(1, 2), (n) => n + 1) * - * console.log(result) - * // { _id: 'Chunk', values: [ 2, 3 ] } + * console.log(Chunk.toArray(result)) // [2, 3] * ``` * - * @since 2.0.0 * @category mapping + * @since 2.0.0 */ (self: NonEmptyChunk, f: (a: A, i: number) => B): NonEmptyChunk; /** * Transforms the elements of a chunk using the specified mapping function. * If the input chunk is non-empty, the resulting chunk will also be non-empty. * - * @example + * **Example** (Mapping values) * * ```ts * import { Chunk } from "effect" * * const result = Chunk.map(Chunk.make(1, 2), (n) => n + 1) * - * console.log(result) - * // { _id: 'Chunk', values: [ 2, 3 ] } + * console.log(Chunk.toArray(result)) // [2, 3] * ``` * - * @since 2.0.0 * @category mapping + * @since 2.0.0 */ (self: Chunk, f: (a: A, i: number) => B): Chunk; }; /** - * Statefully maps over the chunk, producing new elements of type `B`. + * Maps over the chunk statefully, producing new elements of type `B`. + * + * **Example** (Mapping with accumulated state) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2217,14 +2375,15 @@ export declare const map: { * console.log(Chunk.toArray(indexed)) // ["0: hello", "1: world", "2: effect"] * ``` * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ export declare const mapAccum: { /** - * Statefully maps over the chunk, producing new elements of type `B`. + * Maps over the chunk statefully, producing new elements of type `B`. + * + * **Example** (Mapping with accumulated state) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2247,14 +2406,15 @@ export declare const mapAccum: { * console.log(Chunk.toArray(indexed)) // ["0: hello", "1: world", "2: effect"] * ``` * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ (s: S, f: (s: S, a: A) => readonly [S, B]): (self: Chunk) => [S, Chunk]; /** - * Statefully maps over the chunk, producing new elements of type `B`. + * Maps over the chunk statefully, producing new elements of type `B`. + * + * **Example** (Mapping with accumulated state) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2277,18 +2437,20 @@ export declare const mapAccum: { * console.log(Chunk.toArray(indexed)) // ["0: hello", "1: world", "2: effect"] * ``` * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ (self: Chunk, s: S, f: (s: S, a: A) => readonly [S, B]): [S, Chunk]; }; /** * Splits a chunk using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. + * + * **Example** (Partitioning with a Result) * - * @example * ```ts * import { Chunk, Result } from "effect" * @@ -2307,10 +2469,12 @@ export declare const partition: { /** * Splits a chunk using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. + * + * **Example** (Partitioning with a Result) * - * @example * ```ts * import { Chunk, Result } from "effect" * @@ -2329,10 +2493,12 @@ export declare const partition: { /** * Splits a chunk using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. + * + * **Example** (Partitioning with a Result) * - * @example * ```ts * import { Chunk, Result } from "effect" * @@ -2350,12 +2516,18 @@ export declare const partition: { (self: Chunk, f: (input: A, i: number) => Result): [excluded: Chunk, satisfying: Chunk]; }; /** - * Partitions the elements of this chunk into two chunks. + * Separates a chunk of `Result` values into a chunk of failures and a chunk of + * successes. + * + * **Details** + * + * The returned tuple is `[failures, successes]`, preserving the original order + * within each side. + * + * **Example** (Separating failures and successes) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Result from "effect/Result" + * import { Chunk, Result } from "effect" * * const chunk = Chunk.make( * Result.succeed(1), @@ -2383,7 +2555,8 @@ export declare const separate: (self: Chunk>) => [Chunk, C /** * Retrieves the size of the chunk. * - * @example + * **Example** (Getting chunk size) + * * ```ts * import { Chunk } from "effect" * @@ -2396,12 +2569,12 @@ export declare const separate: (self: Chunk>) => [Chunk, C */ export declare const size: (self: Chunk) => number; /** - * Sort the elements of a Chunk in increasing order, creating a new Chunk. + * Sorts the elements of a `Chunk` in increasing order, creating a new `Chunk`. + * + * **Example** (Sorting chunks) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6) * const sorted = Chunk.sort(numbers, Order.Number) @@ -2417,17 +2590,17 @@ export declare const size: (self: Chunk) => number; * console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ export declare const sort: { /** - * Sort the elements of a Chunk in increasing order, creating a new Chunk. + * Sorts the elements of a `Chunk` in increasing order, creating a new `Chunk`. + * + * **Example** (Sorting chunks) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6) * const sorted = Chunk.sort(numbers, Order.Number) @@ -2443,17 +2616,17 @@ export declare const sort: { * console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ (O: Order.Order): (self: Chunk) => Chunk; /** - * Sort the elements of a Chunk in increasing order, creating a new Chunk. + * Sorts the elements of a `Chunk` in increasing order, creating a new `Chunk`. + * + * **Example** (Sorting chunks) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6) * const sorted = Chunk.sort(numbers, Order.Number) @@ -2469,18 +2642,18 @@ export declare const sort: { * console.log(Chunk.toArray(sortedWords)) // ["apple", "banana", "cherry"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ (self: Chunk, O: Order.Order): Chunk; }; /** - * Sorts the elements of a Chunk based on a projection function. + * Sorts the elements of a `Chunk` based on a projection function. + * + * **Example** (Sorting chunks by a derived value) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const people = Chunk.make( * { name: "Alice", age: 30 }, @@ -2504,17 +2677,17 @@ export declare const sort: { * console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ export declare const sortWith: { /** - * Sorts the elements of a Chunk based on a projection function. + * Sorts the elements of a `Chunk` based on a projection function. + * + * **Example** (Sorting chunks by a derived value) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const people = Chunk.make( * { name: "Alice", age: 30 }, @@ -2538,17 +2711,17 @@ export declare const sortWith: { * console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ (f: (a: A) => B, order: Order.Order): (self: Chunk) => Chunk; /** - * Sorts the elements of a Chunk based on a projection function. + * Sorts the elements of a `Chunk` based on a projection function. + * + * **Example** (Sorting chunks by a derived value) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Order from "effect/Order" + * import { Chunk, Order } from "effect" * * const people = Chunk.make( * { name: "Alice", age: 30 }, @@ -2572,15 +2745,16 @@ export declare const sortWith: { * console.log(Chunk.toArray(byLength)) // ["a", "ab", "abc"] * ``` * - * @since 2.0.0 * @category sorting + * @since 2.0.0 */ (self: Chunk, f: (a: A) => B, order: Order.Order): Chunk; }; /** * Returns two splits of this chunk at the specified index. * - * @example + * **Example** (Splitting at an index) + * * ```ts * import { Chunk } from "effect" * @@ -2600,14 +2774,15 @@ export declare const sortWith: { * console.log(Chunk.toArray(empty2)) // [] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ export declare const splitAt: { /** * Returns two splits of this chunk at the specified index. * - * @example + * **Example** (Splitting at an index) + * * ```ts * import { Chunk } from "effect" * @@ -2627,14 +2802,15 @@ export declare const splitAt: { * console.log(Chunk.toArray(empty2)) // [] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (n: number): (self: Chunk) => [beforeIndex: Chunk, fromIndex: Chunk]; /** * Returns two splits of this chunk at the specified index. * - * @example + * **Example** (Splitting at an index) + * * ```ts * import { Chunk } from "effect" * @@ -2654,16 +2830,23 @@ export declare const splitAt: { * console.log(Chunk.toArray(empty2)) // [] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (self: Chunk, n: number): [beforeIndex: Chunk, fromIndex: Chunk]; }; /** - * Splits a `NonEmptyChunk` into two segments, with the first segment containing a maximum of `n` elements. - * The value of `n` must be `>= 1`. + * Splits a `NonEmptyChunk` at `n`, returning a non-empty prefix and the + * remaining suffix. + * + * **Details** + * + * `n` is floored and normalized to at least `1`. If `n` is greater than or + * equal to the chunk length, the first result is the original chunk and the + * second result is empty. + * + * **Example** (Splitting non-empty chunks at an index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2686,10 +2869,17 @@ export declare const splitAt: { */ export declare const splitNonEmptyAt: { /** - * Splits a `NonEmptyChunk` into two segments, with the first segment containing a maximum of `n` elements. - * The value of `n` must be `>= 1`. + * Splits a `NonEmptyChunk` at `n`, returning a non-empty prefix and the + * remaining suffix. + * + * **Details** + * + * `n` is floored and normalized to at least `1`. If `n` is greater than or + * equal to the chunk length, the first result is the original chunk and the + * second result is empty. + * + * **Example** (Splitting non-empty chunks at an index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2712,10 +2902,17 @@ export declare const splitNonEmptyAt: { */ (n: number): (self: NonEmptyChunk) => [beforeIndex: NonEmptyChunk, fromIndex: Chunk]; /** - * Splits a `NonEmptyChunk` into two segments, with the first segment containing a maximum of `n` elements. - * The value of `n` must be `>= 1`. + * Splits a `NonEmptyChunk` at `n`, returning a non-empty prefix and the + * remaining suffix. + * + * **Details** + * + * `n` is floored and normalized to at least `1`. If `n` is greater than or + * equal to the chunk length, the first result is the original chunk and the + * second result is empty. + * + * **Example** (Splitting non-empty chunks at an index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2739,9 +2936,15 @@ export declare const splitNonEmptyAt: { (self: NonEmptyChunk, n: number): [beforeIndex: NonEmptyChunk, fromIndex: Chunk]; }; /** - * Splits this chunk into `n` equally sized chunks. + * Splits a chunk into up to `n` chunks, distributing elements in order. + * + * **Details** + * + * The chunk size is derived from the input length and `n`; the final chunk may + * contain fewer elements than the others. + * + * **Example** (Splitting chunks into groups) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2762,14 +2965,20 @@ export declare const splitNonEmptyAt: { * // [[1, 2, 3, 4, 5, 6, 7, 8, 9]] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ export declare const split: { /** - * Splits this chunk into `n` equally sized chunks. + * Splits a chunk into up to `n` chunks, distributing elements in order. + * + * **Details** + * + * The chunk size is derived from the input length and `n`; the final chunk may + * contain fewer elements than the others. + * + * **Example** (Splitting chunks into groups) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2790,14 +2999,20 @@ export declare const split: { * // [[1, 2, 3, 4, 5, 6, 7, 8, 9]] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (n: number): (self: Chunk) => Chunk>; /** - * Splits this chunk into `n` equally sized chunks. + * Splits a chunk into up to `n` chunks, distributing elements in order. + * + * **Details** + * + * The chunk size is derived from the input length and `n`; the final chunk may + * contain fewer elements than the others. + * + * **Example** (Splitting chunks into groups) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2818,8 +3033,8 @@ export declare const split: { * // [[1, 2, 3, 4, 5, 6, 7, 8, 9]] * ``` * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (self: Chunk, n: number): Chunk>; }; @@ -2827,7 +3042,8 @@ export declare const split: { * Splits this chunk on the first element that matches this predicate. * Returns a tuple containing two chunks: the first one is before the match, and the second one is from the match onward. * - * @example + * **Example** (Splitting at a matching element) + * * ```ts * import { Chunk } from "effect" * @@ -2855,7 +3071,8 @@ export declare const splitWhere: { * Splits this chunk on the first element that matches this predicate. * Returns a tuple containing two chunks: the first one is before the match, and the second one is from the match onward. * - * @example + * **Example** (Splitting at a matching element) + * * ```ts * import { Chunk } from "effect" * @@ -2883,7 +3100,8 @@ export declare const splitWhere: { * Splits this chunk on the first element that matches this predicate. * Returns a tuple containing two chunks: the first one is before the match, and the second one is from the match onward. * - * @example + * **Example** (Splitting at a matching element) + * * ```ts * import { Chunk } from "effect" * @@ -2909,9 +3127,10 @@ export declare const splitWhere: { (self: Chunk, predicate: Predicate): [beforeMatch: Chunk, fromMatch: Chunk]; }; /** - * Returns every elements after the first. + * Returns every element after the first safely, or `None` when the chunk is empty. + * + * **Example** (Getting the tail safely) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2925,14 +3144,15 @@ export declare const splitWhere: { * console.log(Chunk.tail(empty)) // Option.none() * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const tail: (self: Chunk) => O.Option>; /** - * Returns every elements after the first. + * Returns every element after the first from a non-empty chunk. + * + * **Example** (Getting the tail of a non-empty chunk) * - * @example * ```ts * import { Chunk } from "effect" * @@ -2948,14 +3168,15 @@ export declare const tail: (self: Chunk) => O.Option>; * // Chunk.tailNonEmpty(Chunk.empty()) // TypeScript error * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const tailNonEmpty: (self: NonEmptyChunk) => Chunk; /** * Takes the last `n` elements. * - * @example + * **Example** (Taking elements from the end) + * * ```ts * import { Chunk } from "effect" * @@ -2972,14 +3193,15 @@ export declare const tailNonEmpty: (self: NonEmptyChunk) => Chunk; * console.log(Chunk.toArray(none)) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const takeRight: { /** * Takes the last `n` elements. * - * @example + * **Example** (Taking elements from the end) + * * ```ts * import { Chunk } from "effect" * @@ -2996,14 +3218,15 @@ export declare const takeRight: { * console.log(Chunk.toArray(none)) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (n: number): (self: Chunk) => Chunk; /** * Takes the last `n` elements. * - * @example + * **Example** (Taking elements from the end) + * * ```ts * import { Chunk } from "effect" * @@ -3020,15 +3243,16 @@ export declare const takeRight: { * console.log(Chunk.toArray(none)) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Chunk, n: number): Chunk; }; /** * Takes all elements so long as the predicate returns true. * - * @example + * **Example** (Taking elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * @@ -3046,14 +3270,15 @@ export declare const takeRight: { * console.log(Chunk.toArray(all)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const takeWhile: { /** * Takes all elements so long as the predicate returns true. * - * @example + * **Example** (Taking elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * @@ -3071,14 +3296,15 @@ export declare const takeWhile: { * console.log(Chunk.toArray(all)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (refinement: Refinement, B>): (self: Chunk) => Chunk; /** * Takes all elements so long as the predicate returns true. * - * @example + * **Example** (Taking elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * @@ -3096,14 +3322,15 @@ export declare const takeWhile: { * console.log(Chunk.toArray(all)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (predicate: Predicate>): (self: Chunk) => Chunk; /** * Takes all elements so long as the predicate returns true. * - * @example + * **Example** (Taking elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * @@ -3121,14 +3348,15 @@ export declare const takeWhile: { * console.log(Chunk.toArray(all)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Chunk, refinement: Refinement): Chunk; /** * Takes all elements so long as the predicate returns true. * - * @example + * **Example** (Taking elements while a predicate matches) + * * ```ts * import { Chunk } from "effect" * @@ -3146,15 +3374,16 @@ export declare const takeWhile: { * console.log(Chunk.toArray(all)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Chunk, predicate: Predicate): Chunk; }; /** * Creates a Chunks of unique values, in order, from all given Chunks. * - * @example + * **Example** (Unioning chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3170,14 +3399,15 @@ export declare const takeWhile: { * console.log(Chunk.toArray(unified)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const union: { /** * Creates a Chunks of unique values, in order, from all given Chunks. * - * @example + * **Example** (Unioning chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3193,14 +3423,15 @@ export declare const union: { * console.log(Chunk.toArray(unified)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (that: Chunk): (self: Chunk) => Chunk; /** * Creates a Chunks of unique values, in order, from all given Chunks. * - * @example + * **Example** (Unioning chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3216,15 +3447,17 @@ export declare const union: { * console.log(Chunk.toArray(unified)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Chunk, that: Chunk): Chunk; }; /** - * Remove duplicates from an array, keeping the first occurrence of an element. + * Removes duplicate elements from a `Chunk`, preserving the first occurrence + * of each value. + * + * **Example** (Removing duplicate values) * - * @example * ```ts * import { Chunk } from "effect" * @@ -3243,14 +3476,15 @@ export declare const union: { * console.log(Chunk.toArray(uniqueDeduped)) // [1, 2, 3] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const dedupe: (self: Chunk) => Chunk; /** * Deduplicates adjacent elements that are identical. * - * @example + * **Example** (Removing adjacent duplicates) + * * ```ts * import { Chunk } from "effect" * @@ -3264,16 +3498,19 @@ export declare const dedupe: (self: Chunk) => Chunk; * console.log(Chunk.toArray(mixedResult)) // ["a", "b", "a"] * ``` * - * @since 2.0.0 * @category filtering + * @since 2.0.0 */ export declare const dedupeAdjacent: (self: Chunk) => Chunk; /** - * Takes a `Chunk` of pairs and return two corresponding `Chunk`s. + * Takes a `Chunk` of pairs and returns two corresponding `Chunk`s. + * + * **Details** + * + * This function is the reverse of `zip`. * - * Note: The function is reverse of `zip`. + * **Example** (Unzipping pairs) * - * @example * ```ts * import { Chunk } from "effect" * @@ -3293,14 +3530,15 @@ export declare const dedupeAdjacent: (self: Chunk) => Chunk; * console.log(Chunk.toArray(emptyStrs)) // [] * ``` * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const unzip: (self: Chunk) => [Chunk, Chunk]; /** * Zips this chunk pointwise with the specified chunk using the specified combiner. * - * @example + * **Example** (Zipping chunks with a function) + * * ```ts * import { Chunk } from "effect" * @@ -3316,14 +3554,15 @@ export declare const unzip: (self: Chunk) => [Chunk, C * console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ export declare const zipWith: { /** * Zips this chunk pointwise with the specified chunk using the specified combiner. * - * @example + * **Example** (Zipping chunks with a function) + * * ```ts * import { Chunk } from "effect" * @@ -3339,14 +3578,15 @@ export declare const zipWith: { * console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ (that: Chunk, f: (a: A, b: B) => C): (self: Chunk) => Chunk; /** * Zips this chunk pointwise with the specified chunk using the specified combiner. * - * @example + * **Example** (Zipping chunks with a function) + * * ```ts * import { Chunk } from "effect" * @@ -3362,15 +3602,16 @@ export declare const zipWith: { * console.log(Chunk.toArray(mixed)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ (self: Chunk, that: Chunk, f: (a: A, b: B) => C): Chunk; }; /** * Zips this chunk pointwise with the specified chunk. * - * @example + * **Example** (Zipping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3386,14 +3627,15 @@ export declare const zipWith: { * console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ export declare const zip: { /** * Zips this chunk pointwise with the specified chunk. * - * @example + * **Example** (Zipping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3409,14 +3651,15 @@ export declare const zip: { * console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ (that: Chunk): (self: Chunk) => Chunk<[A, B]>; /** * Zips this chunk pointwise with the specified chunk. * - * @example + * **Example** (Zipping chunks) + * * ```ts * import { Chunk } from "effect" * @@ -3432,15 +3675,16 @@ export declare const zip: { * console.log(Chunk.toArray(zipped)) // [[1, "a"], [2, "b"]] * ``` * - * @since 2.0.0 * @category zipping + * @since 2.0.0 */ (self: Chunk, that: Chunk): Chunk<[A, B]>; }; /** - * Delete the element at the specified index, creating a new `Chunk`. + * Deletes the element at the specified index, creating a new `Chunk`. + * + * **Example** (Removing an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -3462,9 +3706,10 @@ export declare const zip: { */ export declare const remove: { /** - * Delete the element at the specified index, creating a new `Chunk`. + * Deletes the element at the specified index, creating a new `Chunk`. + * + * **Example** (Removing an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -3486,9 +3731,10 @@ export declare const remove: { */ (i: number): (self: Chunk) => Chunk; /** - * Delete the element at the specified index, creating a new `Chunk`. + * Deletes the element at the specified index, creating a new `Chunk`. + * + * **Example** (Removing an element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -3511,10 +3757,11 @@ export declare const remove: { (self: Chunk, i: number): Chunk; }; /** - * Applies a function to the element at the specified index, creating a new `Chunk`, + * Applies a function to the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Modifying an element) + * * ```ts * import { Chunk } from "effect" * @@ -3536,10 +3783,11 @@ export declare const remove: { */ export declare const modify: { /** - * Applies a function to the element at the specified index, creating a new `Chunk`, + * Applies a function to the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Modifying an element) + * * ```ts * import { Chunk } from "effect" * @@ -3561,10 +3809,11 @@ export declare const modify: { */ (i: number, f: (a: A) => B): (self: Chunk) => O.Option>; /** - * Applies a function to the element at the specified index, creating a new `Chunk`, + * Applies a function to the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Modifying an element) + * * ```ts * import { Chunk } from "effect" * @@ -3587,10 +3836,11 @@ export declare const modify: { (self: Chunk, i: number, f: (a: A) => B): O.Option>; }; /** - * Change the element at the specified index, creating a new `Chunk`, + * Changes the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Replacing an element) + * * ```ts * import { Chunk } from "effect" * @@ -3612,10 +3862,11 @@ export declare const modify: { */ export declare const replace: { /** - * Change the element at the specified index, creating a new `Chunk`, + * Changes the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Replacing an element) + * * ```ts * import { Chunk } from "effect" * @@ -3637,10 +3888,11 @@ export declare const replace: { */ (i: number, b: B): (self: Chunk) => O.Option>; /** - * Change the element at the specified index, creating a new `Chunk`, + * Changes the element at the specified index safely, creating a new `Chunk`, * or returns `None` if the index is out of bounds. * - * @example + * **Example** (Replacing an element) + * * ```ts * import { Chunk } from "effect" * @@ -3663,17 +3915,19 @@ export declare const replace: { (self: Chunk, i: number, b: B): O.Option>; }; /** - * Return a Chunk of length n with element i initialized with f(i). + * Returns a non-empty `Chunk` of length `n` with element `i` initialized by `f(i)`. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to `1`. * - * **Note**. `n` is normalized to an integer >= 1. + * **Example** (Generating chunks from indices) * - * @example * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.makeBy(5, (i) => i * 2) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 0, 2, 4, 6, 8 ] } + * console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8] * ``` * * @category constructors @@ -3681,17 +3935,19 @@ export declare const replace: { */ export declare const makeBy: { /** - * Return a Chunk of length n with element i initialized with f(i). + * Returns a non-empty `Chunk` of length `n` with element `i` initialized by `f(i)`. + * + * **Details** * - * **Note**. `n` is normalized to an integer >= 1. + * `n` is normalized to an integer greater than or equal to `1`. + * + * **Example** (Generating chunks from indices) * - * @example * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.makeBy(5, (i) => i * 2) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 0, 2, 4, 6, 8 ] } + * console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8] * ``` * * @category constructors @@ -3699,17 +3955,19 @@ export declare const makeBy: { */ (f: (i: number) => A): (n: number) => NonEmptyChunk; /** - * Return a Chunk of length n with element i initialized with f(i). + * Returns a non-empty `Chunk` of length `n` with element `i` initialized by `f(i)`. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to `1`. * - * **Note**. `n` is normalized to an integer >= 1. + * **Example** (Generating chunks from indices) * - * @example * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.makeBy(5, (i) => i * 2) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 0, 2, 4, 6, 8 ] } + * console.log(Chunk.toArray(chunk)) // [0, 2, 4, 6, 8] * ``` * * @category constructors @@ -3718,15 +3976,21 @@ export declare const makeBy: { (n: number, f: (i: number) => A): NonEmptyChunk; }; /** - * Create a non empty `Chunk` containing a range of integers, including both endpoints. + * Creates a non-empty `Chunk` of consecutive integers from `start` through + * `end`, inclusive. + * + * **Details** + * + * If `start` is greater than `end`, returns a single-element chunk containing + * `start`. + * + * **Example** (Creating a range) * - * @example * ```ts * import { Chunk } from "effect" * * const chunk = Chunk.range(1, 5) - * console.log(chunk) - * // { _id: 'Chunk', values: [ 1, 2, 3, 4, 5 ] } + * console.log(Chunk.toArray(chunk)) // [1, 2, 3, 4, 5] * ``` * * @category constructors @@ -3736,7 +4000,8 @@ export declare const range: (start: number, end: number) => NonEmptyChunk(isEquivalent: (self: A, that: A) => boole * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * - * @example + * **Example** (Finding the first matching element) + * * ```ts * import { Chunk, Option } from "effect" * @@ -3875,7 +4144,8 @@ export declare const findFirst: { * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * - * @example + * **Example** (Finding the first matching element) + * * ```ts * import { Chunk, Option } from "effect" * @@ -3905,7 +4175,8 @@ export declare const findFirst: { * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * - * @example + * **Example** (Finding the first matching element) + * * ```ts * import { Chunk, Option } from "effect" * @@ -3935,7 +4206,8 @@ export declare const findFirst: { * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * - * @example + * **Example** (Finding the first matching element) + * * ```ts * import { Chunk, Option } from "effect" * @@ -3965,7 +4237,8 @@ export declare const findFirst: { * Returns the first element that satisfies the specified * predicate, or `None` if no such element exists. * - * @example + * **Example** (Finding the first matching element) + * * ```ts * import { Chunk, Option } from "effect" * @@ -3993,9 +4266,10 @@ export declare const findFirst: { (self: Chunk, predicate: Predicate): Option; }; /** - * Return the first index for which a predicate holds. + * Returns the first index for which a predicate holds. + * + * **Example** (Finding the first matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4017,9 +4291,10 @@ export declare const findFirst: { */ export declare const findFirstIndex: { /** - * Return the first index for which a predicate holds. + * Returns the first index for which a predicate holds. + * + * **Example** (Finding the first matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4041,9 +4316,10 @@ export declare const findFirstIndex: { */ (predicate: Predicate): (self: Chunk) => O.Option; /** - * Return the first index for which a predicate holds. + * Returns the first index for which a predicate holds. + * + * **Example** (Finding the first matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4066,12 +4342,12 @@ export declare const findFirstIndex: { (self: Chunk, predicate: Predicate): O.Option; }; /** - * Find the last element for which a predicate holds. + * Finds the last element for which a predicate holds. + * + * **Example** (Finding the last matching element) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLast(chunk, (n) => n < 4) @@ -4092,12 +4368,12 @@ export declare const findFirstIndex: { */ export declare const findLast: { /** - * Find the last element for which a predicate holds. + * Finds the last element for which a predicate holds. + * + * **Example** (Finding the last matching element) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLast(chunk, (n) => n < 4) @@ -4118,12 +4394,12 @@ export declare const findLast: { */ (refinement: Refinement, B>): (self: Chunk) => Option; /** - * Find the last element for which a predicate holds. + * Finds the last element for which a predicate holds. + * + * **Example** (Finding the last matching element) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLast(chunk, (n) => n < 4) @@ -4144,12 +4420,12 @@ export declare const findLast: { */ (predicate: Predicate>): (self: Chunk) => Option; /** - * Find the last element for which a predicate holds. + * Finds the last element for which a predicate holds. + * + * **Example** (Finding the last matching element) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLast(chunk, (n) => n < 4) @@ -4170,12 +4446,12 @@ export declare const findLast: { */ (self: Chunk, refinement: Refinement): Option; /** - * Find the last element for which a predicate holds. + * Finds the last element for which a predicate holds. + * + * **Example** (Finding the last matching element) * - * @example * ```ts - * import { Chunk } from "effect" - * import * as Option from "effect/Option" + * import { Chunk, Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLast(chunk, (n) => n < 4) @@ -4197,9 +4473,10 @@ export declare const findLast: { (self: Chunk, predicate: Predicate): Option; }; /** - * Return the last index for which a predicate holds. + * Returns the last index for which a predicate holds. + * + * **Example** (Finding the last matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4221,9 +4498,10 @@ export declare const findLast: { */ export declare const findLastIndex: { /** - * Return the last index for which a predicate holds. + * Returns the last index for which a predicate holds. + * + * **Example** (Finding the last matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4245,9 +4523,10 @@ export declare const findLastIndex: { */ (predicate: Predicate): (self: Chunk) => O.Option; /** - * Return the last index for which a predicate holds. + * Returns the last index for which a predicate holds. + * + * **Example** (Finding the last matching index) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4270,9 +4549,10 @@ export declare const findLastIndex: { (self: Chunk, predicate: Predicate): O.Option; }; /** - * Check if a predicate holds true for every `Chunk` element. + * Checks whether a predicate holds true for every `Chunk` element. + * + * **Example** (Checking every element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4297,9 +4577,10 @@ export declare const findLastIndex: { */ export declare const every: { /** - * Check if a predicate holds true for every `Chunk` element. + * Checks whether a predicate holds true for every `Chunk` element. + * + * **Example** (Checking every element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4324,9 +4605,10 @@ export declare const every: { */ (refinement: Refinement, B>): (self: Chunk) => self is Chunk; /** - * Check if a predicate holds true for every `Chunk` element. + * Checks whether a predicate holds true for every `Chunk` element. + * + * **Example** (Checking every element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4351,9 +4633,10 @@ export declare const every: { */ (predicate: Predicate): (self: Chunk) => boolean; /** - * Check if a predicate holds true for every `Chunk` element. + * Checks whether a predicate holds true for every `Chunk` element. + * + * **Example** (Checking every element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4378,9 +4661,10 @@ export declare const every: { */ (self: Chunk, refinement: Refinement): self is Chunk; /** - * Check if a predicate holds true for every `Chunk` element. + * Checks whether a predicate holds true for every `Chunk` element. + * + * **Example** (Checking every element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4406,9 +4690,10 @@ export declare const every: { (self: Chunk, predicate: Predicate): boolean; }; /** - * Check if a predicate holds true for some `Chunk` element. + * Checks whether a predicate holds true for some `Chunk` element. + * + * **Example** (Checking for some matching element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4430,9 +4715,10 @@ export declare const every: { */ export declare const some: { /** - * Check if a predicate holds true for some `Chunk` element. + * Checks whether a predicate holds true for some `Chunk` element. + * + * **Example** (Checking for some matching element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4454,9 +4740,10 @@ export declare const some: { */ (predicate: Predicate>): (self: Chunk) => self is NonEmptyChunk; /** - * Check if a predicate holds true for some `Chunk` element. + * Checks whether a predicate holds true for some `Chunk` element. + * + * **Example** (Checking for some matching element) * - * @example * ```ts * import { Chunk } from "effect" * @@ -4481,7 +4768,8 @@ export declare const some: { /** * Joins the elements together with "sep" in the middle. * - * @example + * **Example** (Joining chunks into a string) + * * ```ts * import { Chunk } from "effect" * @@ -4509,7 +4797,8 @@ export declare const join: { /** * Joins the elements together with "sep" in the middle. * - * @example + * **Example** (Joining chunks into a string) + * * ```ts * import { Chunk } from "effect" * @@ -4537,7 +4826,8 @@ export declare const join: { /** * Joins the elements together with "sep" in the middle. * - * @example + * **Example** (Joining chunks into a string) + * * ```ts * import { Chunk } from "effect" * @@ -4566,7 +4856,8 @@ export declare const join: { /** * Reduces the elements of a chunk from left to right. * - * @example + * **Example** (Reducing from the left) + * * ```ts * import { Chunk } from "effect" * @@ -4591,7 +4882,8 @@ export declare const reduce: { /** * Reduces the elements of a chunk from left to right. * - * @example + * **Example** (Reducing from the left) + * * ```ts * import { Chunk } from "effect" * @@ -4616,7 +4908,8 @@ export declare const reduce: { /** * Reduces the elements of a chunk from left to right. * - * @example + * **Example** (Reducing from the left) + * * ```ts * import { Chunk } from "effect" * @@ -4642,7 +4935,8 @@ export declare const reduce: { /** * Reduces the elements of a chunk from right to left. * - * @example + * **Example** (Reducing from the right) + * * ```ts * import { Chunk } from "effect" * @@ -4671,7 +4965,8 @@ export declare const reduceRight: { /** * Reduces the elements of a chunk from right to left. * - * @example + * **Example** (Reducing from the right) + * * ```ts * import { Chunk } from "effect" * @@ -4700,7 +4995,8 @@ export declare const reduceRight: { /** * Reduces the elements of a chunk from right to left. * - * @example + * **Example** (Reducing from the right) + * * ```ts * import { Chunk } from "effect" * @@ -4731,7 +5027,8 @@ export declare const reduceRight: { * Creates a `Chunk` of values not included in the other given `Chunk` using the provided `isEquivalent` function. * The order and references of result values are determined by the first `Chunk`. * - * @example + * **Example** (Computing difference with custom equivalence) + * * ```ts * import { Chunk } from "effect" * @@ -4766,7 +5063,8 @@ export declare const differenceWith: (isEquivalent: (self: A, that: A) => boo * Creates a `Chunk` of values not included in the other given `Chunk`. * The order and references of result values are determined by the first `Chunk`. * - * @example + * **Example** (Computing chunk difference) + * * ```ts * import { Chunk } from "effect" * @@ -4795,7 +5093,8 @@ export declare const difference: { * Creates a `Chunk` of values not included in the other given `Chunk`. * The order and references of result values are determined by the first `Chunk`. * - * @example + * **Example** (Computing chunk difference) + * * ```ts * import { Chunk } from "effect" * @@ -4824,7 +5123,8 @@ export declare const difference: { * Creates a `Chunk` of values not included in the other given `Chunk`. * The order and references of result values are determined by the first `Chunk`. * - * @example + * **Example** (Computing chunk difference) + * * ```ts * import { Chunk } from "effect" *