diff --git "a/.opencode/node_modules/effect/dist/Array.d.ts" "b/.opencode/node_modules/effect/dist/Array.d.ts" --- "a/.opencode/node_modules/effect/dist/Array.d.ts" +++ "b/.opencode/node_modules/effect/dist/Array.d.ts" @@ -9,10 +9,12 @@ import * as Reducer from "./Reducer.ts"; import * as Result from "./Result.ts"; import type { NoInfer, TupleOf } from "./Types.ts"; /** - * Reference to the global `Array` constructor. + * Exposes the global array constructor. * - * Use this when you need the native `Array` constructor while the `Array` - * namespace is in scope (e.g. `Array.Array.isArray`, `Array.Array.from`). + * **When to use** + * + * Use to access native JavaScript array constructor methods such as `isArray` + * or `from` from the Effect module namespace. * * **Example** (Using the Array constructor) * @@ -39,8 +41,10 @@ export interface ReadonlyArrayTypeLambda extends TypeLambda { /** * A readonly array guaranteed to have at least one element. * - * Use this type when you need to ensure non-emptiness at the type level while - * preventing mutation. Many Array module functions accept or return this type. + * **When to use** + * + * Use when non-emptiness must be tracked at the type level while preventing mutation. + * Many Array module functions accept or return this type. * * **Example** (Typing a non-empty array) * @@ -61,6 +65,13 @@ export type NonEmptyReadonlyArray = readonly [A, ...Array]; /** * A mutable array guaranteed to have at least one element. * + * **When to use** + * + * Use when mutation is acceptable and non-emptiness must be tracked at the type + * level. + * + * **Details** + * * This is the mutable counterpart of {@link NonEmptyReadonlyArray}. Most Array * module functions return `NonEmptyArray` when the result is guaranteed * non-empty. @@ -84,9 +95,14 @@ export type NonEmptyArray = [A, ...Array]; /** * Creates a `NonEmptyArray` from one or more elements. * - * - Use when you have literal values and want a typed non-empty array. - * - The element type is inferred as the union of all arguments. - * - Always returns a `NonEmptyArray` since at least one argument is required. + * **When to use** + * + * Use when you need to create a typed non-empty array from literal values. + * + * **Details** + * + * The element type is inferred as the union of all arguments. Because at least + * one argument is required, this always returns a `NonEmptyArray`. * * **Example** (Creating an array from values) * @@ -107,9 +123,13 @@ export declare const make: >(...elements /** * Creates a new `Array` of the specified length with all slots uninitialized. * - * - Use when you need a pre-sized array and will fill it imperatively. - * - Elements are typed as `A | undefined` since slots are empty. - * - Prefer {@link makeBy} when you can compute each element from its index. + * **When to use** + * + * Use when you need a pre-sized array that will be filled imperatively. + * + * **Details** + * + * Elements are typed as `A | undefined` because the slots are empty. * * **Example** (Allocating a fixed-size array) * @@ -129,9 +149,15 @@ export declare const allocate: (n: number) => Array; /** * Creates a `NonEmptyArray` of length `n` where element `i` is computed by `f(i)`. * - * - Use when you need an array whose values depend on the index. - * - `n` is normalized to an integer >= 1 — always returns at least one element. - * - Dual: `Array.makeBy(5, f)` or `pipe(5, Array.makeBy(f))`. + * **When to use** + * + * Use when you need to compute each array element from its index. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Generating values from indices) * @@ -152,9 +178,15 @@ export declare const makeBy: { /** * Creates a `NonEmptyArray` of length `n` where element `i` is computed by `f(i)`. * - * - Use when you need an array whose values depend on the index. - * - `n` is normalized to an integer >= 1 — always returns at least one element. - * - Dual: `Array.makeBy(5, f)` or `pipe(5, Array.makeBy(f))`. + * **When to use** + * + * Use when you need to compute each array element from its index. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Generating values from indices) * @@ -175,9 +207,15 @@ export declare const makeBy: { /** * Creates a `NonEmptyArray` of length `n` where element `i` is computed by `f(i)`. * - * - Use when you need an array whose values depend on the index. - * - `n` is normalized to an integer >= 1 — always returns at least one element. - * - Dual: `Array.makeBy(5, f)` or `pipe(5, Array.makeBy(f))`. + * **When to use** + * + * Use when you need to compute each array element from its index. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Generating values from indices) * @@ -200,9 +238,13 @@ export declare const makeBy: { * Creates a `NonEmptyArray` containing a range of integers, inclusive on both * ends. * - * - Use when you need a sequence of consecutive integers. - * - If `start > end`, returns `[start]`. - * - Always returns a `NonEmptyArray`. + * **When to use** + * + * Use when you need a non-empty sequence of consecutive integers. + * + * **Details** + * + * If `start > end`, returns `[start]`. * * **Example** (Creating a range) * @@ -222,9 +264,15 @@ export declare const range: (start: number, end: number) => NonEmptyArray= 1 — always returns at least one element. - * - Dual: `Array.replicate("a", 3)` or `pipe("a", Array.replicate(3))`. + * **When to use** + * + * Use when you need a non-empty array containing repeated copies of one value. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Repeating a value) * @@ -244,9 +292,15 @@ export declare const replicate: { /** * Creates a `NonEmptyArray` containing a value repeated `n` times. * - * - Use when you need multiple copies of the same value. - * - `n` is normalized to an integer >= 1 — always returns at least one element. - * - Dual: `Array.replicate("a", 3)` or `pipe("a", Array.replicate(3))`. + * **When to use** + * + * Use when you need a non-empty array containing repeated copies of one value. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Repeating a value) * @@ -266,9 +320,15 @@ export declare const replicate: { /** * Creates a `NonEmptyArray` containing a value repeated `n` times. * - * - Use when you need multiple copies of the same value. - * - `n` is normalized to an integer >= 1 — always returns at least one element. - * - Dual: `Array.replicate("a", 3)` or `pipe("a", Array.replicate(3))`. + * **When to use** + * + * Use when you need a non-empty array containing repeated copies of one value. + * + * **Details** + * + * `n` is normalized to an integer greater than or equal to 1, so this function + * always returns at least one element. Supports both data-first and data-last + * usage. * * **Example** (Repeating a value) * @@ -289,10 +349,15 @@ export declare const replicate: { /** * Converts an `Iterable` to an `Array`. * - * - If the input is already an array, returns it **by reference** (no copy). - * - Otherwise, creates a new array from the iterable. - * - Use {@link copy} if you need a fresh array even when the input is already - * an array. + * **When to use** + * + * Use to convert any `Iterable` (Set, Generator, etc.) into an array. + * + * **Details** + * + * If the input is already an array, this returns it by reference without + * copying. Otherwise, it creates a new array from the iterable. Use `copy` if + * you need a fresh array even when the input is already an array. * * **Example** (Converting a Set to an array) * @@ -313,9 +378,16 @@ export declare const fromIterable: (collection: Iterable) => Array; /** * Normalizes a value that is either a single element or an array into an array. * - * - If the input is already an array, returns it by reference. - * - If the input is a single value, wraps it in a one-element array. - * - Useful for APIs that accept `A | Array`. + * **When to use** + * + * Use to normalize input that may be a single value or an array into a consistent + * array. + * + * **Details** + * + * If the input is already an array, this returns it by reference. If the input + * is a single value, this wraps it in a one-element array. This is useful for + * APIs that accept `A | Array`. * * **Example** (Normalizing input) * @@ -336,8 +408,15 @@ export declare const ensure: (self: ReadonlyArray | A) => Array; /** * Converts a record into an array of `[key, value]` tuples. * - * - Key order follows `Object.entries` semantics. - * - Returns an empty array for an empty record. + * **When to use** + * + * Use to convert a record into an array of key-value tuples for iteration or + * transformation. + * + * **Details** + * + * Key order follows `Object.entries` semantics. Empty records produce an empty + * array. * * **Example** (Record to entries) * @@ -348,13 +427,20 @@ export declare const ensure: (self: ReadonlyArray | A) => Array; * console.log(result) // [["a", 1], ["b", 2], ["c", 3]] * ``` * - * @category conversions + * @see {@link Record.toEntries} the equivalent function from the Record module + * @see {@link Record.fromEntries} to build a record from an array of tuples + * + * @category converting * @since 2.0.0 */ export declare const fromRecord: (self: Readonly>) => Array<[K, A]>; /** * Converts an `Option` to an array: `Some(a)` becomes `[a]`, `None` becomes `[]`. * + * **When to use** + * + * Use to convert a single `Option` into an array for downstream array operations. + * * **Example** (Option to array) * * ```ts @@ -366,16 +452,21 @@ export declare const fromRecord: (self: Readonly(self: Option.Option) => Array; /** * Pattern-matches on an array, handling empty and non-empty cases separately. * - * - Use when you need to branch on whether an array has elements. - * - `onNonEmpty` receives a `NonEmptyReadonlyArray`. - * - Dual: data-first or data-last. + * **When to use** + * + * Use when you need to branch on whether an array is empty. + * + * **Details** + * + * `onNonEmpty` receives a `NonEmptyReadonlyArray`. Supports both data-first and + * data-last usage. * * **Example** (Branching on emptiness) * @@ -400,9 +491,14 @@ export declare const match: { /** * Pattern-matches on an array, handling empty and non-empty cases separately. * - * - Use when you need to branch on whether an array has elements. - * - `onNonEmpty` receives a `NonEmptyReadonlyArray`. - * - Dual: data-first or data-last. + * **When to use** + * + * Use when you need to branch on whether an array is empty. + * + * **Details** + * + * `onNonEmpty` receives a `NonEmptyReadonlyArray`. Supports both data-first and + * data-last usage. * * **Example** (Branching on emptiness) * @@ -430,9 +526,14 @@ export declare const match: { /** * Pattern-matches on an array, handling empty and non-empty cases separately. * - * - Use when you need to branch on whether an array has elements. - * - `onNonEmpty` receives a `NonEmptyReadonlyArray`. - * - Dual: data-first or data-last. + * **When to use** + * + * Use when you need to branch on whether an array is empty. + * + * **Details** + * + * `onNonEmpty` receives a `NonEmptyReadonlyArray`. Supports both data-first and + * data-last usage. * * **Example** (Branching on emptiness) * @@ -462,8 +563,14 @@ export declare const match: { * Pattern-matches on an array from the left, providing the first element and * the remaining elements separately. * - * - `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. - * - Use when you want to process the first element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * first element plus the remaining elements. + * + * **Details** + * + * `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. * * **Example** (Head and tail destructuring) * @@ -489,8 +596,14 @@ export declare const matchLeft: { * Pattern-matches on an array from the left, providing the first element and * the remaining elements separately. * - * - `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. - * - Use when you want to process the first element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * first element plus the remaining elements. + * + * **Details** + * + * `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. * * **Example** (Head and tail destructuring) * @@ -519,8 +632,14 @@ export declare const matchLeft: { * Pattern-matches on an array from the left, providing the first element and * the remaining elements separately. * - * - `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. - * - Use when you want to process the first element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * first element plus the remaining elements. + * + * **Details** + * + * `onNonEmpty` receives `(head, tail)` where `tail` is the rest of the array. * * **Example** (Head and tail destructuring) * @@ -550,8 +669,14 @@ export declare const matchLeft: { * Pattern-matches on an array from the right, providing all elements except the * last and the last element separately. * - * - `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. - * - Use when you want to process the last element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * elements before the last plus the last element. + * + * **Details** + * + * `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. * * **Example** (Init and last destructuring) * @@ -577,8 +702,14 @@ export declare const matchRight: { * Pattern-matches on an array from the right, providing all elements except the * last and the last element separately. * - * - `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. - * - Use when you want to process the last element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * elements before the last plus the last element. + * + * **Details** + * + * `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. * * **Example** (Init and last destructuring) * @@ -607,8 +738,14 @@ export declare const matchRight: { * Pattern-matches on an array from the right, providing all elements except the * last and the last element separately. * - * - `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. - * - Use when you want to process the last element differently from the rest. + * **When to use** + * + * Use when you need to branch on an array and handle the non-empty case as the + * elements before the last plus the last element. + * + * **Details** + * + * `onNonEmpty` receives `(init, last)` where `init` is everything but the last element. * * **Example** (Init and last destructuring) * @@ -637,8 +774,10 @@ export declare const matchRight: { /** * Adds a single element to the front of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * leading value. * * **Example** (Prepending an element) * @@ -652,15 +791,17 @@ export declare const matchRight: { * @see {@link append} — add to the end * @see {@link prependAll} — prepend multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const prepend: { /** * Adds a single element to the front of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * leading value. * * **Example** (Prepending an element) * @@ -674,15 +815,17 @@ export declare const prepend: { * @see {@link append} — add to the end * @see {@link prependAll} — prepend multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ (head: B): (self: Iterable) => NonEmptyArray; /** * Adds a single element to the front of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * leading value. * * **Example** (Prepending an element) * @@ -696,7 +839,7 @@ export declare const prepend: { * @see {@link append} — add to the end * @see {@link prependAll} — prepend multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, head: B): NonEmptyArray; @@ -704,8 +847,13 @@ export declare const prepend: { /** * Prepends all elements from a prefix iterable to the front of an array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the input. + * **When to use** + * + * Use to prepend multiple elements from an iterable to the front of an array. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Prepending multiple elements) * @@ -719,15 +867,20 @@ export declare const prepend: { * @see {@link prepend} — add a single element to the front * @see {@link appendAll} — add elements to the end * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const prependAll: { /** * Prepends all elements from a prefix iterable to the front of an array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the input. + * **When to use** + * + * Use to prepend multiple elements from an iterable to the front of an array. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Prepending multiple elements) * @@ -741,15 +894,20 @@ export declare const prependAll: { * @see {@link prepend} — add a single element to the front * @see {@link appendAll} — add elements to the end * - * @category concatenating + * @category combining * @since 2.0.0 */ , T extends Iterable>(that: T): (self: S) => ReadonlyArray.OrNonEmpty | ReadonlyArray.Infer>; /** * Prepends all elements from a prefix iterable to the front of an array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the input. + * **When to use** + * + * Use to prepend multiple elements from an iterable to the front of an array. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Prepending multiple elements) * @@ -763,15 +921,20 @@ export declare const prependAll: { * @see {@link prepend} — add a single element to the front * @see {@link appendAll} — add elements to the end * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, that: NonEmptyReadonlyArray): NonEmptyArray; /** * Prepends all elements from a prefix iterable to the front of an array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the input. + * **When to use** + * + * Use to prepend multiple elements from an iterable to the front of an array. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Prepending multiple elements) * @@ -785,15 +948,20 @@ export declare const prependAll: { * @see {@link prepend} — add a single element to the front * @see {@link appendAll} — add elements to the end * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: NonEmptyReadonlyArray, that: Iterable): NonEmptyArray; /** * Prepends all elements from a prefix iterable to the front of an array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the input. + * **When to use** + * + * Use to prepend multiple elements from an iterable to the front of an array. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Prepending multiple elements) * @@ -807,7 +975,7 @@ export declare const prependAll: { * @see {@link prepend} — add a single element to the front * @see {@link appendAll} — add elements to the end * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, that: Iterable): Array; @@ -815,8 +983,10 @@ export declare const prependAll: { /** * Adds a single element to the end of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * trailing value. * * **Example** (Appending an element) * @@ -830,15 +1000,17 @@ export declare const prependAll: { * @see {@link prepend} — add to the front * @see {@link appendAll} — append multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const append: { /** * Adds a single element to the end of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * trailing value. * * **Example** (Appending an element) * @@ -852,15 +1024,17 @@ export declare const append: { * @see {@link prepend} — add to the front * @see {@link appendAll} — append multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ (last: B): (self: Iterable) => NonEmptyArray; /** * Adds a single element to the end of an iterable, returning a `NonEmptyArray`. * - * - Always returns a non-empty array. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to guarantee a non-empty result after adding a required + * trailing value. * * **Example** (Appending an element) * @@ -874,7 +1048,7 @@ export declare const append: { * @see {@link prepend} — add to the front * @see {@link appendAll} — append multiple elements * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, last: B): NonEmptyArray; @@ -882,8 +1056,14 @@ export declare const append: { /** * Concatenates two iterables into a single array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the inputs. + * **When to use** + * + * Use to combine two iterable inputs into a new array with the second input's + * elements after the first. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Concatenating arrays) * @@ -897,15 +1077,21 @@ export declare const append: { * @see {@link append} — add a single element to the end * @see {@link prependAll} — add elements to the front * - * @category concatenating + * @category combining * @since 2.0.0 */ export declare const appendAll: { /** * Concatenates two iterables into a single array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the inputs. + * **When to use** + * + * Use to combine two iterable inputs into a new array with the second input's + * elements after the first. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Concatenating arrays) * @@ -919,15 +1105,21 @@ export declare const appendAll: { * @see {@link append} — add a single element to the end * @see {@link prependAll} — add elements to the front * - * @category concatenating + * @category combining * @since 2.0.0 */ , T extends Iterable>(that: T): (self: S) => ReadonlyArray.OrNonEmpty | ReadonlyArray.Infer>; /** * Concatenates two iterables into a single array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the inputs. + * **When to use** + * + * Use to combine two iterable inputs into a new array with the second input's + * elements after the first. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Concatenating arrays) * @@ -941,15 +1133,21 @@ export declare const appendAll: { * @see {@link append} — add a single element to the end * @see {@link prependAll} — add elements to the front * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, that: NonEmptyReadonlyArray): NonEmptyArray; /** * Concatenates two iterables into a single array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the inputs. + * **When to use** + * + * Use to combine two iterable inputs into a new array with the second input's + * elements after the first. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Concatenating arrays) * @@ -963,15 +1161,21 @@ export declare const appendAll: { * @see {@link append} — add a single element to the end * @see {@link prependAll} — add elements to the front * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: NonEmptyReadonlyArray, that: Iterable): NonEmptyArray; /** * Concatenates two iterables into a single array. * - * - If either input is non-empty, the result is a `NonEmptyArray`. - * - Does not mutate the inputs. + * **When to use** + * + * Use to combine two iterable inputs into a new array with the second input's + * elements after the first. + * + * **Details** + * + * If either input is non-empty, the result is a `NonEmptyArray`. * * **Example** (Concatenating arrays) * @@ -985,17 +1189,23 @@ export declare const appendAll: { * @see {@link append} — add a single element to the end * @see {@link prependAll} — add elements to the front * - * @category concatenating + * @category combining * @since 2.0.0 */ (self: Iterable, that: Iterable): Array; }; /** - * Left-to-right fold that keeps every intermediate accumulator value. + * Folds left-to-right while keeping every intermediate accumulator value. + * + * **When to use** + * + * Use to compute a running accumulator where each intermediate value is needed. * - * - The output length is `input.length + 1` (starts with the initial value). - * - Always returns a `NonEmptyArray` because the initial value is included. - * - Use {@link reduce} if you only need the final accumulated value. + * **Details** + * + * The output length is `input.length + 1` because it starts with the initial + * value. The result is always a `NonEmptyArray`. Use `reduce` if you only need + * the final accumulated value. * * **Example** (Running totals) * @@ -1014,11 +1224,17 @@ export declare const appendAll: { */ export declare const scan: { /** - * Left-to-right fold that keeps every intermediate accumulator value. + * Folds left-to-right while keeping every intermediate accumulator value. + * + * **When to use** + * + * Use to compute a running accumulator where each intermediate value is needed. + * + * **Details** * - * - The output length is `input.length + 1` (starts with the initial value). - * - Always returns a `NonEmptyArray` because the initial value is included. - * - Use {@link reduce} if you only need the final accumulated value. + * The output length is `input.length + 1` because it starts with the initial + * value. The result is always a `NonEmptyArray`. Use `reduce` if you only need + * the final accumulated value. * * **Example** (Running totals) * @@ -1037,11 +1253,17 @@ export declare const scan: { */ (b: B, f: (b: B, a: A) => B): (self: Iterable) => NonEmptyArray; /** - * Left-to-right fold that keeps every intermediate accumulator value. + * Folds left-to-right while keeping every intermediate accumulator value. * - * - The output length is `input.length + 1` (starts with the initial value). - * - Always returns a `NonEmptyArray` because the initial value is included. - * - Use {@link reduce} if you only need the final accumulated value. + * **When to use** + * + * Use to compute a running accumulator where each intermediate value is needed. + * + * **Details** + * + * The output length is `input.length + 1` because it starts with the initial + * value. The result is always a `NonEmptyArray`. Use `reduce` if you only need + * the final accumulated value. * * **Example** (Running totals) * @@ -1061,10 +1283,17 @@ export declare const scan: { (self: Iterable, b: B, f: (b: B, a: A) => B): NonEmptyArray; }; /** - * Right-to-left fold that keeps every intermediate accumulator value. + * Folds right-to-left while keeping every intermediate accumulator value. + * + * **When to use** * - * - The output length is `input.length + 1` (ends with the initial value). - * - Always returns a `NonEmptyArray`. + * Use to compute a running accumulator from right to left where each intermediate + * value is needed. + * + * **Details** + * + * The output length is `input.length + 1` because it ends with the initial + * value. The result is always a `NonEmptyArray`. * * **Example** (Reverse running totals) * @@ -1083,10 +1312,17 @@ export declare const scan: { */ export declare const scanRight: { /** - * Right-to-left fold that keeps every intermediate accumulator value. + * Folds right-to-left while keeping every intermediate accumulator value. + * + * **When to use** + * + * Use to compute a running accumulator from right to left where each intermediate + * value is needed. * - * - The output length is `input.length + 1` (ends with the initial value). - * - Always returns a `NonEmptyArray`. + * **Details** + * + * The output length is `input.length + 1` because it ends with the initial + * value. The result is always a `NonEmptyArray`. * * **Example** (Reverse running totals) * @@ -1105,10 +1341,17 @@ export declare const scanRight: { */ (b: B, f: (b: B, a: A) => B): (self: Iterable) => NonEmptyArray; /** - * Right-to-left fold that keeps every intermediate accumulator value. + * Folds right-to-left while keeping every intermediate accumulator value. + * + * **When to use** + * + * Use to compute a running accumulator from right to left where each intermediate + * value is needed. * - * - The output length is `input.length + 1` (ends with the initial value). - * - Always returns a `NonEmptyArray`. + * **Details** + * + * The output length is `input.length + 1` because it ends with the initial + * value. The result is always a `NonEmptyArray`. * * **Example** (Reverse running totals) * @@ -1128,10 +1371,16 @@ export declare const scanRight: { (self: Iterable, b: B, f: (b: B, a: A) => B): NonEmptyArray; }; /** - * Tests whether a value is an `Array`. + * Checks whether a value is an `Array`. + * + * **When to use** + * + * Use to verify a value is a mutable array, narrowing its type to `Array`. + * + * **Details** * - * - Acts as a type guard narrowing the input to `Array`. - * - Delegates to `globalThis.Array.isArray`. + * Acts as a type guard narrowing the input to `Array` and delegates to + * `globalThis.Array.isArray`. * * **Example** (Type-guarding an unknown value) * @@ -1150,10 +1399,16 @@ export declare const scanRight: { */ export declare const isArray: { /** - * Tests whether a value is an `Array`. + * Checks whether a value is an `Array`. * - * - Acts as a type guard narrowing the input to `Array`. - * - Delegates to `globalThis.Array.isArray`. + * **When to use** + * + * Use to verify a value is a mutable array, narrowing its type to `Array`. + * + * **Details** + * + * Acts as a type guard narrowing the input to `Array` and delegates to + * `globalThis.Array.isArray`. * * **Example** (Type-guarding an unknown value) * @@ -1172,10 +1427,16 @@ export declare const isArray: { */ (self: unknown): self is Array; /** - * Tests whether a value is an `Array`. + * Checks whether a value is an `Array`. + * + * **When to use** * - * - Acts as a type guard narrowing the input to `Array`. - * - Delegates to `globalThis.Array.isArray`. + * Use to verify a value is a mutable array, narrowing its type to `Array`. + * + * **Details** + * + * Acts as a type guard narrowing the input to `Array` and delegates to + * `globalThis.Array.isArray`. * * **Example** (Type-guarding an unknown value) * @@ -1195,7 +1456,7 @@ export declare const isArray: { (self: T): self is Extract>; }; /** - * Tests whether a mutable `Array` is empty, narrowing the type to `[]`. + * Checks whether a mutable `Array` is empty, narrowing the type to `[]`. * * **Example** (Checking for an empty array) * @@ -1210,11 +1471,11 @@ export declare const isArray: { * @see {@link isArrayNonEmpty} — opposite check * * @category guards - * @since 2.0.0 + * @since 4.0.0 */ export declare const isArrayEmpty: (self: Array) => self is []; /** - * Tests whether a `ReadonlyArray` is empty, narrowing the type to `readonly []`. + * Checks whether a `ReadonlyArray` is empty, narrowing the type to `readonly []`. * * **Example** (Checking for an empty readonly array) * @@ -1229,13 +1490,18 @@ export declare const isArrayEmpty: (self: Array) => self is []; * @see {@link isReadonlyArrayNonEmpty} — opposite check * * @category guards - * @since 2.0.0 + * @since 4.0.0 */ export declare const isReadonlyArrayEmpty: (self: ReadonlyArray) => self is readonly []; /** - * Tests whether a mutable `Array` is non-empty, narrowing the type to + * Checks whether a mutable `Array` is non-empty, narrowing the type to * `NonEmptyArray`. * + * **When to use** + * + * Use when you need the narrowed value to remain a mutable `Array` after proving + * it has at least one element. + * * **Example** (Checking for a non-empty array) * * ```ts @@ -1249,13 +1515,18 @@ export declare const isReadonlyArrayEmpty: (self: ReadonlyArray) => self i * @see {@link isArrayEmpty} — opposite check * * @category guards - * @since 2.0.0 + * @since 4.0.0 */ export declare const isArrayNonEmpty: (self: Array) => self is NonEmptyArray; /** - * Tests whether a `ReadonlyArray` is non-empty, narrowing the type to + * Checks whether a `ReadonlyArray` is non-empty, narrowing the type to * `NonEmptyReadonlyArray`. * + * **When to use** + * + * Use when you need to prove a readonly array has at least one element without + * requiring mutable array methods afterward. + * * **Example** (Checking for a non-empty readonly array) * * ```ts @@ -1269,12 +1540,16 @@ export declare const isArrayNonEmpty: (self: Array) => self is NonEmptyArr * @see {@link isReadonlyArrayEmpty} — opposite check * * @category guards - * @since 2.0.0 + * @since 4.0.0 */ export declare const isReadonlyArrayNonEmpty: (self: ReadonlyArray) => self is NonEmptyReadonlyArray; /** * Returns the number of elements in a `ReadonlyArray`. * + * **When to use** + * + * Use when you need length as a composable function rather than a property access. + * * **Example** (Getting the length) * * ```ts @@ -1288,11 +1563,17 @@ export declare const isReadonlyArrayNonEmpty: (self: ReadonlyArray) => sel */ export declare const length: (self: ReadonlyArray) => number; /** - * Safely reads an element at the given index, returning `Option.some` or + * Reads an element at the given index safely, returning `Option.some` or * `Option.none` if the index is out of bounds. * - * - The index is floored to an integer. - * - Never throws. + * **When to use** + * + * Use when you need to read an array element by index and handle an + * out-of-bounds index as `Option.none`. + * + * **Details** + * + * The index is floored to an integer. This never throws. * * **Example** (Safe index access) * @@ -1303,20 +1584,26 @@ export declare const length: (self: ReadonlyArray) => number; * console.log(Array.get([1, 2, 3], 10)) // None * ``` * - * @see {@link getUnsafe} — throws on out of bounds - * @see {@link head} — get the first element - * @see {@link last} — get the last element + * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds + * @see {@link head} for reading the first element as an `Option` + * @see {@link last} for reading the last element as an `Option` * * @category getters * @since 2.0.0 */ export declare const get: { /** - * Safely reads an element at the given index, returning `Option.some` or + * Reads an element at the given index safely, returning `Option.some` or * `Option.none` if the index is out of bounds. * - * - The index is floored to an integer. - * - Never throws. + * **When to use** + * + * Use when you need to read an array element by index and handle an + * out-of-bounds index as `Option.none`. + * + * **Details** + * + * The index is floored to an integer. This never throws. * * **Example** (Safe index access) * @@ -1327,20 +1614,26 @@ export declare const get: { * console.log(Array.get([1, 2, 3], 10)) // None * ``` * - * @see {@link getUnsafe} — throws on out of bounds - * @see {@link head} — get the first element - * @see {@link last} — get the last element + * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds + * @see {@link head} for reading the first element as an `Option` + * @see {@link last} for reading the last element as an `Option` * * @category getters * @since 2.0.0 */ (index: number): (self: ReadonlyArray) => Option.Option; /** - * Safely reads an element at the given index, returning `Option.some` or + * Reads an element at the given index safely, returning `Option.some` or * `Option.none` if the index is out of bounds. * - * - The index is floored to an integer. - * - Never throws. + * **When to use** + * + * Use when you need to read an array element by index and handle an + * out-of-bounds index as `Option.none`. + * + * **Details** + * + * The index is floored to an integer. This never throws. * * **Example** (Safe index access) * @@ -1351,9 +1644,9 @@ export declare const get: { * console.log(Array.get([1, 2, 3], 10)) // None * ``` * - * @see {@link getUnsafe} — throws on out of bounds - * @see {@link head} — get the first element - * @see {@link last} — get the last element + * @see {@link getUnsafe} for indexed access that throws when the index is out of bounds + * @see {@link head} for reading the first element as an `Option` + * @see {@link last} for reading the last element as an `Option` * * @category getters * @since 2.0.0 @@ -1363,8 +1656,15 @@ export declare const get: { /** * Reads an element at the given index, throwing if the index is out of bounds. * - * - Throws an `Error` with the message `"Index out of bounds: "`. - * - Prefer {@link get} for safe access. + * **When to use** + * + * Use to read an array element at a known valid index when out-of-bounds would + * be a programming error. + * + * **Details** + * + * Throws an `Error` with the message `"Index out of bounds: "`. Prefer + * `get` for safe access. * * **Example** (Unsafe index access) * @@ -1377,15 +1677,22 @@ export declare const get: { * * @see {@link get} — safe version returning `Option` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ export declare const getUnsafe: { /** * Reads an element at the given index, throwing if the index is out of bounds. * - * - Throws an `Error` with the message `"Index out of bounds: "`. - * - Prefer {@link get} for safe access. + * **When to use** + * + * Use to read an array element at a known valid index when out-of-bounds would + * be a programming error. + * + * **Details** + * + * Throws an `Error` with the message `"Index out of bounds: "`. Prefer + * `get` for safe access. * * **Example** (Unsafe index access) * @@ -1398,15 +1705,22 @@ export declare const getUnsafe: { * * @see {@link get} — safe version returning `Option` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ (index: number): (self: ReadonlyArray) => A; /** * Reads an element at the given index, throwing if the index is out of bounds. * - * - Throws an `Error` with the message `"Index out of bounds: "`. - * - Prefer {@link get} for safe access. + * **When to use** + * + * Use to read an array element at a known valid index when out-of-bounds would + * be a programming error. + * + * **Details** + * + * Throws an `Error` with the message `"Index out of bounds: "`. Prefer + * `get` for safe access. * * **Example** (Unsafe index access) * @@ -1419,16 +1733,22 @@ export declare const getUnsafe: { * * @see {@link get} — safe version returning `Option` * - * @since 2.0.0 * @category unsafe + * @since 4.0.0 */ (self: ReadonlyArray, index: number): A; }; /** * Splits a non-empty array into its first element and the remaining elements. * - * - Returns a tuple `[head, tail]`. - * - Requires a `NonEmptyReadonlyArray`. + * **When to use** + * + * Use when you have a `NonEmptyReadonlyArray` and need both its first element + * and the remaining elements as separate values. + * + * **Details** + * + * Returns a tuple `[head, tail]` and requires a `NonEmptyReadonlyArray`. * * **Example** (Destructuring head and tail) * @@ -1439,9 +1759,9 @@ export declare const getUnsafe: { * console.log(result) // [1, [2, 3, 4]] * ``` * - * @see {@link unappend} — split into init + last - * @see {@link headNonEmpty} — get only the head - * @see {@link tailNonEmpty} — get only the tail + * @see {@link unappend} for splitting a non-empty array into init and last + * @see {@link headNonEmpty} for getting only the first element + * @see {@link tailNonEmpty} for getting only the elements after the first * * @category splitting * @since 2.0.0 @@ -1451,8 +1771,14 @@ export declare const unprepend: (self: NonEmptyReadonlyArray) => [firstEle * Splits a non-empty array into all elements except the last, and the last * element. * - * - Returns a tuple `[init, last]`. - * - Requires a `NonEmptyReadonlyArray`. + * **When to use** + * + * Use when you need to split a non-empty array into the elements before the + * last element and the last element. + * + * **Details** + * + * Returns a tuple `[init, last]` and requires a `NonEmptyReadonlyArray`. * * **Example** (Destructuring init and last) * @@ -1463,18 +1789,22 @@ export declare const unprepend: (self: NonEmptyReadonlyArray) => [firstEle * console.log(result) // [[1, 2, 3], 4] * ``` * - * @see {@link unprepend} — split into head + tail - * @see {@link initNonEmpty} — get only the init - * @see {@link lastNonEmpty} — get only the last + * @see {@link unprepend} for splitting a non-empty array into head and tail + * @see {@link initNonEmpty} for getting only the elements before the last + * @see {@link lastNonEmpty} for getting only the last element * * @category splitting * @since 2.0.0 */ export declare const unappend: (self: NonEmptyReadonlyArray) => [arrayWithoutLastElement: Array, lastElement: A]; /** - * Returns the first element of an array wrapped in `Option.some`, or + * Returns the first element of an array safely wrapped in `Option.some`, or * `Option.none` if the array is empty. * + * **When to use** + * + * Use to safely get the first element of an array that may be empty. + * * **Example** (Getting the first element) * * ```ts @@ -1495,6 +1825,11 @@ export declare const head: (self: ReadonlyArray) => Option.Option; * Returns the first element of a `NonEmptyReadonlyArray` directly (no `Option` * wrapper). * + * **When to use** + * + * Use to get the first element without `Option` wrapping when the array is known + * to be non-empty. + * * **Example** (Getting the head of a non-empty array) * * ```ts @@ -1510,9 +1845,13 @@ export declare const head: (self: ReadonlyArray) => Option.Option; */ export declare const headNonEmpty: (self: NonEmptyReadonlyArray) => A; /** - * Returns the last element of an array wrapped in `Option.some`, or + * Returns the last element of an array safely wrapped in `Option.some`, or * `Option.none` if the array is empty. * + * **When to use** + * + * Use to safely get the last element of an array that may be empty. + * * **Example** (Getting the last element) * * ```ts @@ -1533,6 +1872,11 @@ export declare const last: (self: ReadonlyArray) => Option.Option; * Returns the last element of a `NonEmptyReadonlyArray` directly (no `Option` * wrapper). * + * **When to use** + * + * Use to get the last element without `Option` wrapping when the array is known + * to be non-empty. + * * **Example** (Getting the last of a non-empty array) * * ```ts @@ -1548,10 +1892,15 @@ export declare const last: (self: ReadonlyArray) => Option.Option; */ export declare const lastNonEmpty: (self: NonEmptyReadonlyArray) => A; /** - * Returns all elements except the first, wrapped in an `Option`. + * Returns all elements except the first safely, wrapped in an `Option`. + * + * **When to use** + * + * Use to safely get all elements after the first when the iterable may be empty. * - * - Allocates a new array via `slice(1)`. - * - Returns `Option.none()` for empty inputs. + * **Details** + * + * Allocates a new array via `slice(1)`. Empty inputs return `Option.none()`. * * **Example** (Getting the tail) * @@ -1572,6 +1921,10 @@ export declare function tail(self: Iterable): Option.Option>; /** * Returns all elements except the first of a `NonEmptyReadonlyArray`. * + * **When to use** + * + * Use to get all elements after the first when the array is known to be non-empty. + * * **Example** (Getting the tail of a non-empty array) * * ```ts @@ -1588,10 +1941,16 @@ export declare function tail(self: Iterable): Option.Option>; */ export declare const tailNonEmpty: (self: NonEmptyReadonlyArray) => Array; /** - * Returns all elements except the last, wrapped in an `Option`. + * Returns all elements except the last safely, wrapped in an `Option`. + * + * **When to use** * - * - Allocates a new array via `slice(0, -1)`. - * - Returns `Option.none()` for empty inputs. + * Use to safely get all elements before the last when the iterable may be empty. + * + * **Details** + * + * Allocates a new array via `slice(0, -1)`. Empty inputs return + * `Option.none()`. * * **Example** (Getting init) * @@ -1612,6 +1971,10 @@ export declare function init(self: Iterable): Option.Option>; /** * Returns all elements except the last of a `NonEmptyReadonlyArray`. * + * **When to use** + * + * Use to get all elements before the last when the array is known to be non-empty. + * * **Example** (Getting init of a non-empty array) * * ```ts @@ -1630,8 +1993,13 @@ export declare const initNonEmpty: (self: NonEmptyReadonlyArray) => Array< /** * Keeps the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep up to the first `n` elements from an iterable as a new array. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the start) * @@ -1641,9 +2009,9 @@ export declare const initNonEmpty: (self: NonEmptyReadonlyArray) => Array< * console.log(Array.take([1, 2, 3, 4, 5], 3)) // [1, 2, 3] * ``` * - * @see {@link takeRight} — keep from the end - * @see {@link takeWhile} — keep while predicate holds - * @see {@link drop} — remove from the start + * @see {@link takeRight} for keeping elements from the end + * @see {@link takeWhile} for keeping an initial prefix while a predicate holds + * @see {@link drop} for removing elements from the start * * @category getters * @since 2.0.0 @@ -1652,8 +2020,13 @@ export declare const take: { /** * Keeps the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep up to the first `n` elements from an iterable as a new array. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the start) * @@ -1663,9 +2036,9 @@ export declare const take: { * console.log(Array.take([1, 2, 3, 4, 5], 3)) // [1, 2, 3] * ``` * - * @see {@link takeRight} — keep from the end - * @see {@link takeWhile} — keep while predicate holds - * @see {@link drop} — remove from the start + * @see {@link takeRight} for keeping elements from the end + * @see {@link takeWhile} for keeping an initial prefix while a predicate holds + * @see {@link drop} for removing elements from the start * * @category getters * @since 2.0.0 @@ -1674,8 +2047,13 @@ export declare const take: { /** * Keeps the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep up to the first `n` elements from an iterable as a new array. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the start) * @@ -1685,9 +2063,9 @@ export declare const take: { * console.log(Array.take([1, 2, 3, 4, 5], 3)) // [1, 2, 3] * ``` * - * @see {@link takeRight} — keep from the end - * @see {@link takeWhile} — keep while predicate holds - * @see {@link drop} — remove from the start + * @see {@link takeRight} for keeping elements from the end + * @see {@link takeWhile} for keeping an initial prefix while a predicate holds + * @see {@link drop} for removing elements from the start * * @category getters * @since 2.0.0 @@ -1697,8 +2075,13 @@ export declare const take: { /** * Keeps the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep the last `n` elements of an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the end) * @@ -1718,8 +2101,13 @@ export declare const takeRight: { /** * Keeps the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep the last `n` elements of an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the end) * @@ -1739,8 +2127,13 @@ export declare const takeRight: { /** * Keeps the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to keep the last `n` elements of an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. Returns an empty array when `n <= 0`. * * **Example** (Taking from the end) * @@ -1762,8 +2155,15 @@ export declare const takeRight: { * Takes elements from the start while the predicate holds, stopping at the * first element that fails. * - * - Supports refinements for type narrowing. - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to keep the leading elements of an iterable while each element satisfies + * a predicate, returning the retained prefix as an array. + * + * **Details** + * + * Supports refinements for type narrowing. The predicate receives + * `(element, index)`. * * **Example** (Taking while condition holds) * @@ -1773,9 +2173,9 @@ export declare const takeRight: { * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2] * ``` * - * @see {@link take} — take a fixed count - * @see {@link dropWhile} — drop while predicate holds - * @see {@link span} — split into matching prefix + rest + * @see {@link take} for keeping a fixed number of leading elements + * @see {@link dropWhile} for removing the matching prefix and keeping the rest + * @see {@link span} for splitting the matching prefix from the remaining elements * * @category getters * @since 2.0.0 @@ -1785,8 +2185,15 @@ export declare const takeWhile: { * Takes elements from the start while the predicate holds, stopping at the * first element that fails. * - * - Supports refinements for type narrowing. - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to keep the leading elements of an iterable while each element satisfies + * a predicate, returning the retained prefix as an array. + * + * **Details** + * + * Supports refinements for type narrowing. The predicate receives + * `(element, index)`. * * **Example** (Taking while condition holds) * @@ -1796,9 +2203,9 @@ export declare const takeWhile: { * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2] * ``` * - * @see {@link take} — take a fixed count - * @see {@link dropWhile} — drop while predicate holds - * @see {@link span} — split into matching prefix + rest + * @see {@link take} for keeping a fixed number of leading elements + * @see {@link dropWhile} for removing the matching prefix and keeping the rest + * @see {@link span} for splitting the matching prefix from the remaining elements * * @category getters * @since 2.0.0 @@ -1808,8 +2215,15 @@ export declare const takeWhile: { * Takes elements from the start while the predicate holds, stopping at the * first element that fails. * - * - Supports refinements for type narrowing. - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to keep the leading elements of an iterable while each element satisfies + * a predicate, returning the retained prefix as an array. + * + * **Details** + * + * Supports refinements for type narrowing. The predicate receives + * `(element, index)`. * * **Example** (Taking while condition holds) * @@ -1819,9 +2233,9 @@ export declare const takeWhile: { * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2] * ``` * - * @see {@link take} — take a fixed count - * @see {@link dropWhile} — drop while predicate holds - * @see {@link span} — split into matching prefix + rest + * @see {@link take} for keeping a fixed number of leading elements + * @see {@link dropWhile} for removing the matching prefix and keeping the rest + * @see {@link span} for splitting the matching prefix from the remaining elements * * @category getters * @since 2.0.0 @@ -1831,8 +2245,15 @@ export declare const takeWhile: { * Takes elements from the start while the predicate holds, stopping at the * first element that fails. * - * - Supports refinements for type narrowing. - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to keep the leading elements of an iterable while each element satisfies + * a predicate, returning the retained prefix as an array. + * + * **Details** + * + * Supports refinements for type narrowing. The predicate receives + * `(element, index)`. * * **Example** (Taking while condition holds) * @@ -1842,9 +2263,9 @@ export declare const takeWhile: { * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2] * ``` * - * @see {@link take} — take a fixed count - * @see {@link dropWhile} — drop while predicate holds - * @see {@link span} — split into matching prefix + rest + * @see {@link take} for keeping a fixed number of leading elements + * @see {@link dropWhile} for removing the matching prefix and keeping the rest + * @see {@link span} for splitting the matching prefix from the remaining elements * * @category getters * @since 2.0.0 @@ -1854,8 +2275,15 @@ export declare const takeWhile: { * Takes elements from the start while the predicate holds, stopping at the * first element that fails. * - * - Supports refinements for type narrowing. - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to keep the leading elements of an iterable while each element satisfies + * a predicate, returning the retained prefix as an array. + * + * **Details** + * + * Supports refinements for type narrowing. The predicate receives + * `(element, index)`. * * **Example** (Taking while condition holds) * @@ -1865,9 +2293,9 @@ export declare const takeWhile: { * console.log(Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4)) // [1, 3, 2] * ``` * - * @see {@link take} — take a fixed count - * @see {@link dropWhile} — drop while predicate holds - * @see {@link span} — split into matching prefix + rest + * @see {@link take} for keeping a fixed number of leading elements + * @see {@link dropWhile} for removing the matching prefix and keeping the rest + * @see {@link span} for splitting the matching prefix from the remaining elements * * @category getters * @since 2.0.0 @@ -1877,8 +2305,18 @@ export declare const takeWhile: { /** * Takes elements from the start while a `Filter` succeeds, collecting transformed values. * - * - The filter receives `(element, index)`. - * - Stops at the first filter failure. + * **When to use** + * + * Use when you need to take a prefix from an iterable while a function can + * successfully extract or transform elements, stopping at the first element + * that produces a failure result. + * + * **Details** + * + * The filter receives `(element, index)` and processing stops at the first + * filter failure. + * + * @see {@link takeWhile} for taking a prefix based on a boolean predicate * * @category getters * @since 4.0.0 @@ -1887,8 +2325,18 @@ export declare const takeWhileFilter: { /** * Takes elements from the start while a `Filter` succeeds, collecting transformed values. * - * - The filter receives `(element, index)`. - * - Stops at the first filter failure. + * **When to use** + * + * Use when you need to take a prefix from an iterable while a function can + * successfully extract or transform elements, stopping at the first element + * that produces a failure result. + * + * **Details** + * + * The filter receives `(element, index)` and processing stops at the first + * filter failure. + * + * @see {@link takeWhile} for taking a prefix based on a boolean predicate * * @category getters * @since 4.0.0 @@ -1897,8 +2345,18 @@ export declare const takeWhileFilter: { /** * Takes elements from the start while a `Filter` succeeds, collecting transformed values. * - * - The filter receives `(element, index)`. - * - Stops at the first filter failure. + * **When to use** + * + * Use when you need to take a prefix from an iterable while a function can + * successfully extract or transform elements, stopping at the first element + * that produces a failure result. + * + * **Details** + * + * The filter receives `(element, index)` and processing stops at the first + * filter failure. + * + * @see {@link takeWhile} for taking a prefix based on a boolean predicate * * @category getters * @since 4.0.0 @@ -1909,9 +2367,16 @@ export declare const takeWhileFilter: { * Splits an iterable into two arrays: the longest prefix where the predicate * holds, and the remaining elements. * - * - Equivalent to `[takeWhile(pred), dropWhile(pred)]` but more efficient - * (single pass). - * - Supports refinements for type narrowing of the prefix. + * **When to use** + * + * Use when you need both the longest predicate-matching prefix and the + * remaining elements. + * + * **Details** + * + * Equivalent to `[takeWhile(pred), dropWhile(pred)]`, but more efficient + * because it runs in a single pass. Supports refinements for type narrowing of + * the prefix. * * **Example** (Splitting at predicate boundary) * @@ -1921,9 +2386,9 @@ export declare const takeWhileFilter: { * console.log(Array.span([1, 3, 2, 4, 5], (x) => x % 2 === 1)) // [[1, 3], [2, 4, 5]] * ``` * - * @see {@link takeWhile} — keep only the matching prefix - * @see {@link dropWhile} — keep only the rest - * @see {@link splitWhere} — split at the first element matching a predicate + * @see {@link takeWhile} for keeping only the matching prefix + * @see {@link dropWhile} for keeping only the elements after the matching prefix + * @see {@link splitWhere} for splitting at the first element that satisfies a predicate * * @category splitting * @since 2.0.0 @@ -1933,9 +2398,16 @@ export declare const span: { * Splits an iterable into two arrays: the longest prefix where the predicate * holds, and the remaining elements. * - * - Equivalent to `[takeWhile(pred), dropWhile(pred)]` but more efficient - * (single pass). - * - Supports refinements for type narrowing of the prefix. + * **When to use** + * + * Use when you need both the longest predicate-matching prefix and the + * remaining elements. + * + * **Details** + * + * Equivalent to `[takeWhile(pred), dropWhile(pred)]`, but more efficient + * because it runs in a single pass. Supports refinements for type narrowing of + * the prefix. * * **Example** (Splitting at predicate boundary) * @@ -1945,9 +2417,9 @@ export declare const span: { * console.log(Array.span([1, 3, 2, 4, 5], (x) => x % 2 === 1)) // [[1, 3], [2, 4, 5]] * ``` * - * @see {@link takeWhile} — keep only the matching prefix - * @see {@link dropWhile} — keep only the rest - * @see {@link splitWhere} — split at the first element matching a predicate + * @see {@link takeWhile} for keeping only the matching prefix + * @see {@link dropWhile} for keeping only the elements after the matching prefix + * @see {@link splitWhere} for splitting at the first element that satisfies a predicate * * @category splitting * @since 2.0.0 @@ -1957,9 +2429,16 @@ export declare const span: { * Splits an iterable into two arrays: the longest prefix where the predicate * holds, and the remaining elements. * - * - Equivalent to `[takeWhile(pred), dropWhile(pred)]` but more efficient - * (single pass). - * - Supports refinements for type narrowing of the prefix. + * **When to use** + * + * Use when you need both the longest predicate-matching prefix and the + * remaining elements. + * + * **Details** + * + * Equivalent to `[takeWhile(pred), dropWhile(pred)]`, but more efficient + * because it runs in a single pass. Supports refinements for type narrowing of + * the prefix. * * **Example** (Splitting at predicate boundary) * @@ -1969,9 +2448,9 @@ export declare const span: { * console.log(Array.span([1, 3, 2, 4, 5], (x) => x % 2 === 1)) // [[1, 3], [2, 4, 5]] * ``` * - * @see {@link takeWhile} — keep only the matching prefix - * @see {@link dropWhile} — keep only the rest - * @see {@link splitWhere} — split at the first element matching a predicate + * @see {@link takeWhile} for keeping only the matching prefix + * @see {@link dropWhile} for keeping only the elements after the matching prefix + * @see {@link splitWhere} for splitting at the first element that satisfies a predicate * * @category splitting * @since 2.0.0 @@ -1981,9 +2460,16 @@ export declare const span: { * Splits an iterable into two arrays: the longest prefix where the predicate * holds, and the remaining elements. * - * - Equivalent to `[takeWhile(pred), dropWhile(pred)]` but more efficient - * (single pass). - * - Supports refinements for type narrowing of the prefix. + * **When to use** + * + * Use when you need both the longest predicate-matching prefix and the + * remaining elements. + * + * **Details** + * + * Equivalent to `[takeWhile(pred), dropWhile(pred)]`, but more efficient + * because it runs in a single pass. Supports refinements for type narrowing of + * the prefix. * * **Example** (Splitting at predicate boundary) * @@ -1993,9 +2479,9 @@ export declare const span: { * console.log(Array.span([1, 3, 2, 4, 5], (x) => x % 2 === 1)) // [[1, 3], [2, 4, 5]] * ``` * - * @see {@link takeWhile} — keep only the matching prefix - * @see {@link dropWhile} — keep only the rest - * @see {@link splitWhere} — split at the first element matching a predicate + * @see {@link takeWhile} for keeping only the matching prefix + * @see {@link dropWhile} for keeping only the elements after the matching prefix + * @see {@link splitWhere} for splitting at the first element that satisfies a predicate * * @category splitting * @since 2.0.0 @@ -2005,9 +2491,16 @@ export declare const span: { * Splits an iterable into two arrays: the longest prefix where the predicate * holds, and the remaining elements. * - * - Equivalent to `[takeWhile(pred), dropWhile(pred)]` but more efficient - * (single pass). - * - Supports refinements for type narrowing of the prefix. + * **When to use** + * + * Use when you need both the longest predicate-matching prefix and the + * remaining elements. + * + * **Details** + * + * Equivalent to `[takeWhile(pred), dropWhile(pred)]`, but more efficient + * because it runs in a single pass. Supports refinements for type narrowing of + * the prefix. * * **Example** (Splitting at predicate boundary) * @@ -2017,9 +2510,9 @@ export declare const span: { * console.log(Array.span([1, 3, 2, 4, 5], (x) => x % 2 === 1)) // [[1, 3], [2, 4, 5]] * ``` * - * @see {@link takeWhile} — keep only the matching prefix - * @see {@link dropWhile} — keep only the rest - * @see {@link splitWhere} — split at the first element matching a predicate + * @see {@link takeWhile} for keeping only the matching prefix + * @see {@link dropWhile} for keeping only the elements after the matching prefix + * @see {@link splitWhere} for splitting at the first element that satisfies a predicate * * @category splitting * @since 2.0.0 @@ -2029,8 +2522,15 @@ export declare const span: { /** * Removes the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns a copy of the full array when `n <= 0`. + * **When to use** + * + * Use to keep the suffix of an iterable after skipping a fixed number of + * leading elements. + * + * **Details** + * + * `n` is clamped to `[0, length]`. When `n <= 0`, this returns a copy of the + * full array. * * **Example** (Dropping from the start) * @@ -2040,9 +2540,9 @@ export declare const span: { * console.log(Array.drop([1, 2, 3, 4, 5], 2)) // [3, 4, 5] * ``` * - * @see {@link dropRight} — remove from the end - * @see {@link dropWhile} — remove while predicate holds - * @see {@link take} — keep from the start + * @see {@link dropRight} for removing a fixed number of elements from the end + * @see {@link dropWhile} for removing a prefix based on a predicate instead of a fixed count + * @see {@link take} for keeping a fixed number of elements from the start * * @category getters * @since 2.0.0 @@ -2051,8 +2551,15 @@ export declare const drop: { /** * Removes the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns a copy of the full array when `n <= 0`. + * **When to use** + * + * Use to keep the suffix of an iterable after skipping a fixed number of + * leading elements. + * + * **Details** + * + * `n` is clamped to `[0, length]`. When `n <= 0`, this returns a copy of the + * full array. * * **Example** (Dropping from the start) * @@ -2062,9 +2569,9 @@ export declare const drop: { * console.log(Array.drop([1, 2, 3, 4, 5], 2)) // [3, 4, 5] * ``` * - * @see {@link dropRight} — remove from the end - * @see {@link dropWhile} — remove while predicate holds - * @see {@link take} — keep from the start + * @see {@link dropRight} for removing a fixed number of elements from the end + * @see {@link dropWhile} for removing a prefix based on a predicate instead of a fixed count + * @see {@link take} for keeping a fixed number of elements from the start * * @category getters * @since 2.0.0 @@ -2073,8 +2580,15 @@ export declare const drop: { /** * Removes the first `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. - * - Returns a copy of the full array when `n <= 0`. + * **When to use** + * + * Use to keep the suffix of an iterable after skipping a fixed number of + * leading elements. + * + * **Details** + * + * `n` is clamped to `[0, length]`. When `n <= 0`, this returns a copy of the + * full array. * * **Example** (Dropping from the start) * @@ -2084,9 +2598,9 @@ export declare const drop: { * console.log(Array.drop([1, 2, 3, 4, 5], 2)) // [3, 4, 5] * ``` * - * @see {@link dropRight} — remove from the end - * @see {@link dropWhile} — remove while predicate holds - * @see {@link take} — keep from the start + * @see {@link dropRight} for removing a fixed number of elements from the end + * @see {@link dropWhile} for removing a prefix based on a predicate instead of a fixed count + * @see {@link take} for keeping a fixed number of elements from the start * * @category getters * @since 2.0.0 @@ -2096,7 +2610,13 @@ export declare const drop: { /** * Removes the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. + * **When to use** + * + * Use to remove the last `n` elements from an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. * * **Example** (Dropping from the end) * @@ -2116,7 +2636,13 @@ export declare const dropRight: { /** * Removes the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. + * **When to use** + * + * Use to remove the last `n` elements from an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. * * **Example** (Dropping from the end) * @@ -2136,7 +2662,13 @@ export declare const dropRight: { /** * Removes the last `n` elements, creating a new array. * - * - `n` is clamped to `[0, length]`. + * **When to use** + * + * Use to remove the last `n` elements from an iterable. + * + * **Details** + * + * `n` is clamped to `[0, length]`. * * **Example** (Dropping from the end) * @@ -2157,7 +2689,13 @@ export declare const dropRight: { /** * Drops elements from the start while the predicate holds, returning the rest. * - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to remove a leading prefix of elements that satisfy a predicate. + * + * **Details** + * + * The predicate receives `(element, index)`. * * **Example** (Dropping while condition holds) * @@ -2177,7 +2715,13 @@ export declare const dropWhile: { /** * Drops elements from the start while the predicate holds, returning the rest. * - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to remove a leading prefix of elements that satisfy a predicate. + * + * **Details** + * + * The predicate receives `(element, index)`. * * **Example** (Dropping while condition holds) * @@ -2197,7 +2741,13 @@ export declare const dropWhile: { /** * Drops elements from the start while the predicate holds, returning the rest. * - * - The predicate receives `(element, index)`. + * **When to use** + * + * Use to remove a leading prefix of elements that satisfy a predicate. + * + * **Details** + * + * The predicate receives `(element, index)`. * * **Example** (Dropping while condition holds) * @@ -2218,8 +2768,18 @@ export declare const dropWhile: { /** * Drops elements from the start while a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Returns the remaining original elements after the first filter failure. + * **When to use** + * + * Use when you need to drop a prefix from an iterable by computing a `Result` + * per element instead of using a simple boolean predicate. + * + * **Details** + * + * The filter receives `(element, index)`. The result contains the remaining + * original elements after the first filter failure. + * + * @see {@link dropWhile} for dropping a prefix with a simple boolean predicate + * @see {@link takeWhileFilter} for keeping only the matching prefix * * @category getters * @since 4.0.0 @@ -2228,8 +2788,18 @@ export declare const dropWhileFilter: { /** * Drops elements from the start while a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Returns the remaining original elements after the first filter failure. + * **When to use** + * + * Use when you need to drop a prefix from an iterable by computing a `Result` + * per element instead of using a simple boolean predicate. + * + * **Details** + * + * The filter receives `(element, index)`. The result contains the remaining + * original elements after the first filter failure. + * + * @see {@link dropWhile} for dropping a prefix with a simple boolean predicate + * @see {@link takeWhileFilter} for keeping only the matching prefix * * @category getters * @since 4.0.0 @@ -2238,8 +2808,18 @@ export declare const dropWhileFilter: { /** * Drops elements from the start while a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Returns the remaining original elements after the first filter failure. + * **When to use** + * + * Use when you need to drop a prefix from an iterable by computing a `Result` + * per element instead of using a simple boolean predicate. + * + * **Details** + * + * The filter receives `(element, index)`. The result contains the remaining + * original elements after the first filter failure. + * + * @see {@link dropWhile} for dropping a prefix with a simple boolean predicate + * @see {@link takeWhileFilter} for keeping only the matching prefix * * @category getters * @since 4.0.0 @@ -2250,6 +2830,11 @@ export declare const dropWhileFilter: { * Returns the index of the first element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the first matching element from the start of an + * iterable. + * * **Example** (Finding an index) * * ```ts @@ -2269,6 +2854,11 @@ export declare const findFirstIndex: { * Returns the index of the first element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the first matching element from the start of an + * iterable. + * * **Example** (Finding an index) * * ```ts @@ -2288,6 +2878,11 @@ export declare const findFirstIndex: { * Returns the index of the first element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the first matching element from the start of an + * iterable. + * * **Example** (Finding an index) * * ```ts @@ -2308,6 +2903,10 @@ export declare const findFirstIndex: { * Returns the index of the last element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the last matching element from the end of an array. + * * **Example** (Finding the last matching index) * * ```ts @@ -2327,6 +2926,10 @@ export declare const findLastIndex: { * Returns the index of the last element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the last matching element from the end of an array. + * * **Example** (Finding the last matching index) * * ```ts @@ -2346,6 +2949,10 @@ export declare const findLastIndex: { * Returns the index of the last element matching the predicate, wrapped in an * `Option`. * + * **When to use** + * + * Use to find the index of the last matching element from the end of an array. + * * **Example** (Finding the last matching index) * * ```ts @@ -2366,9 +2973,16 @@ export declare const findLastIndex: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2390,9 +3004,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2414,9 +3035,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2438,9 +3066,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2462,9 +3097,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2486,9 +3128,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2510,9 +3159,16 @@ export declare const findFirst: { * Returns the first element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Accepts a predicate `(a, i) => boolean`, a refinement, or a function - * `(a, i) => Option` for simultaneous find-and-transform. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to scan an iterable in iteration order and return the first selected + * element or mapped value as an `Option`. + * + * **Details** + * + * Accepts a predicate `(a, i) => boolean`, a refinement, or a function + * `(a, i) => Option` for simultaneous find-and-transform. If no element + * matches, this returns `Option.none()`. * * **Example** (Finding the first match) * @@ -2532,8 +3188,18 @@ export declare const findFirst: { (self: Iterable, predicate: (a: A, i: number) => boolean): Option.Option; }; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2551,8 +3217,18 @@ export declare const findFirst: { */ export declare const findFirstWithIndex: { /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2570,8 +3246,18 @@ export declare const findFirstWithIndex: { */ (f: (a: NoInfer, i: number) => Option.Option): (self: Iterable) => Option.Option<[B, number]>; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2589,8 +3275,18 @@ export declare const findFirstWithIndex: { */ (refinement: (a: NoInfer, i: number) => a is B): (self: Iterable) => Option.Option<[B, number]>; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2608,8 +3304,18 @@ export declare const findFirstWithIndex: { */ (predicate: (a: NoInfer, i: number) => boolean): (self: Iterable) => Option.Option<[A, number]>; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2627,8 +3333,18 @@ export declare const findFirstWithIndex: { */ (self: Iterable, f: (a: A, i: number) => Option.Option): Option.Option<[B, number]>; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2646,8 +3362,18 @@ export declare const findFirstWithIndex: { */ (self: Iterable, refinement: (a: A, i: number) => a is B): Option.Option<[B, number]>; /** - * Returns a tuple `[element, index]` of the first element matching a - * predicate, wrapped in an `Option`. + * Returns the first selected value together with its index, wrapped in an + * `Option`. + * + * **When to use** + * + * Use to find both the first matching element and its index in one pass. + * + * **Details** + * + * Accepts a predicate, a refinement, or a function returning `Option`. For an + * `Option`-returning function, returns `[mappedValue, index]` for the first + * `Some`, or `Option.none()` if no element is selected. * * **Example** (Finding element with its index) * @@ -2669,8 +3395,14 @@ export declare const findFirstWithIndex: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2691,8 +3423,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2713,8 +3451,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2735,8 +3479,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2757,8 +3507,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2779,8 +3535,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2801,8 +3563,14 @@ export declare const findLast: { * Returns the last element matching a predicate, refinement, or mapping * function, wrapped in `Option`. * - * - Searches from the end of the array. - * - Returns `Option.none()` if no element matches. + * **When to use** + * + * Use to find the last matching element from the end of an array. + * + * **Details** + * + * Searches from the end of the array. If no element matches, this returns + * `Option.none()`. * * **Example** (Finding the last match) * @@ -2821,11 +3589,16 @@ export declare const findLast: { (self: Iterable, predicate: (a: A, i: number) => boolean): Option.Option; }; /** - * Inserts an element at the specified index, returning a new `NonEmptyArray` + * Inserts an element at the specified index safely, returning a new `NonEmptyArray` * wrapped in an `Option`. * - * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends). - * - Does not mutate the input. + * **When to use** + * + * Use to insert a single element at a specific position in an array. + * + * **Details** + * + * Valid indices are `0` to `length`, inclusive. Inserting at `length` appends. * * **Example** (Inserting at an index) * @@ -2843,11 +3616,16 @@ export declare const findLast: { */ export declare const insertAt: { /** - * Inserts an element at the specified index, returning a new `NonEmptyArray` + * Inserts an element at the specified index safely, returning a new `NonEmptyArray` * wrapped in an `Option`. * - * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends). - * - Does not mutate the input. + * **When to use** + * + * Use to insert a single element at a specific position in an array. + * + * **Details** + * + * Valid indices are `0` to `length`, inclusive. Inserting at `length` appends. * * **Example** (Inserting at an index) * @@ -2865,11 +3643,16 @@ export declare const insertAt: { */ (i: number, b: B): (self: Iterable) => Option.Option>; /** - * Inserts an element at the specified index, returning a new `NonEmptyArray` + * Inserts an element at the specified index safely, returning a new `NonEmptyArray` * wrapped in an `Option`. * - * - Valid indices: `0` to `length` (inclusive — inserting at `length` appends). - * - Does not mutate the input. + * **When to use** + * + * Use to insert a single element at a specific position in an array. + * + * **Details** + * + * Valid indices are `0` to `length`, inclusive. Inserting at `length` appends. * * **Example** (Inserting at an index) * @@ -2888,10 +3671,16 @@ export declare const insertAt: { (self: Iterable, i: number, b: B): Option.Option>; }; /** - * Replaces the element at the specified index with a new value, returning a new - * array, wrapped in an `Option`. + * Replaces the element at the specified index safely with a new value, returning the + * updated array in `Option.some`. + * + * **When to use** + * + * Use to set a fixed replacement value at a specific index. + * + * **Details** * - * - Does not mutate the input. + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Replacing an element) * @@ -2909,10 +3698,16 @@ export declare const insertAt: { */ export declare const replace: { /** - * Replaces the element at the specified index with a new value, returning a new - * array, wrapped in an `Option`. + * Replaces the element at the specified index safely with a new value, returning the + * updated array in `Option.some`. * - * - Does not mutate the input. + * **When to use** + * + * Use to set a fixed replacement value at a specific index. + * + * **Details** + * + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Replacing an element) * @@ -2930,10 +3725,16 @@ export declare const replace: { */ (i: number, b: B): = Iterable>(self: S) => Option.Option | B>>; /** - * Replaces the element at the specified index with a new value, returning a new - * array, wrapped in an `Option`. + * Replaces the element at the specified index safely with a new value, returning the + * updated array in `Option.some`. + * + * **When to use** * - * - Does not mutate the input. + * Use to set a fixed replacement value at a specific index. + * + * **Details** + * + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Replacing an element) * @@ -2952,10 +3753,17 @@ export declare const replace: { = Iterable>(self: S, i: number, b: B): Option.Option | B>>; }; /** - * Applies a function to the element at the specified index, returning a new - * array, wrapped in an `Option`. + * Applies a function to the element at the specified index safely, returning the + * updated array in `Option.some`. + * + * **When to use** + * + * Use to derive a replacement value from an array element at a specific index + * while leaving the other elements unchanged. * - * - Does not mutate the input. + * **Details** + * + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Modifying an element) * @@ -2975,10 +3783,17 @@ export declare const replace: { */ export declare const modify: { /** - * Applies a function to the element at the specified index, returning a new - * array, wrapped in an `Option`. + * Applies a function to the element at the specified index safely, returning the + * updated array in `Option.some`. + * + * **When to use** + * + * Use to derive a replacement value from an array element at a specific index + * while leaving the other elements unchanged. + * + * **Details** * - * - Does not mutate the input. + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Modifying an element) * @@ -2998,10 +3813,17 @@ export declare const modify: { */ = Iterable>(i: number, f: (a: ReadonlyArray.Infer) => B): (self: S) => Option.Option | B>>; /** - * Applies a function to the element at the specified index, returning a new - * array, wrapped in an `Option`. + * Applies a function to the element at the specified index safely, returning the + * updated array in `Option.some`. * - * - Does not mutate the input. + * **When to use** + * + * Use to derive a replacement value from an array element at a specific index + * while leaving the other elements unchanged. + * + * **Details** + * + * Returns `Option.none()` when the index is out of bounds. * * **Example** (Modifying an element) * @@ -3025,7 +3847,10 @@ export declare const modify: { * Removes the element at the specified index, returning a new array. If the * index is out of bounds, returns a copy of the original. * - * - Does not mutate the input. + * **When to use** + * + * Use when you want a missing index to be a no-op and need a fresh array result + * instead of an optional failure. * * **Example** (Removing an element) * @@ -3047,7 +3872,10 @@ export declare const remove: { * Removes the element at the specified index, returning a new array. If the * index is out of bounds, returns a copy of the original. * - * - Does not mutate the input. + * **When to use** + * + * Use when you want a missing index to be a no-op and need a fresh array result + * instead of an optional failure. * * **Example** (Removing an element) * @@ -3069,7 +3897,10 @@ export declare const remove: { * Removes the element at the specified index, returning a new array. If the * index is out of bounds, returns a copy of the original. * - * - Does not mutate the input. + * **When to use** + * + * Use when you want a missing index to be a no-op and need a fresh array result + * instead of an optional failure. * * **Example** (Removing an element) * @@ -3091,8 +3922,14 @@ export declare const remove: { /** * Reverses an iterable into a new array. * - * - Does not mutate the input. - * - Preserves `NonEmptyArray` in the return type. + * **When to use** + * + * Use to reverse an iterable into a new array without mutating the original + * input. + * + * **Details** + * + * Preserves `NonEmptyArray` in the return type. * * **Example** (Reversing an array) * @@ -3109,10 +3946,14 @@ export declare const reverse: >(self: S) => S extends No /** * Sorts an array by the given `Order`, returning a new array. * - * - Does not mutate the input. - * - Preserves `NonEmptyArray` in the return type. - * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for - * multi-key sorting. + * **When to use** + * + * Use to sort an array using a single `Order` comparator. + * + * **Details** + * + * Preserves `NonEmptyArray` in the return type. Use `sortWith` to sort by a + * derived key, or `sortBy` for multi-key sorting. * * **Example** (Sorting numbers) * @@ -3132,10 +3973,14 @@ export declare const sort: { /** * Sorts an array by the given `Order`, returning a new array. * - * - Does not mutate the input. - * - Preserves `NonEmptyArray` in the return type. - * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for - * multi-key sorting. + * **When to use** + * + * Use to sort an array using a single `Order` comparator. + * + * **Details** + * + * Preserves `NonEmptyArray` in the return type. Use `sortWith` to sort by a + * derived key, or `sortBy` for multi-key sorting. * * **Example** (Sorting numbers) * @@ -3155,10 +4000,14 @@ export declare const sort: { /** * Sorts an array by the given `Order`, returning a new array. * - * - Does not mutate the input. - * - Preserves `NonEmptyArray` in the return type. - * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for - * multi-key sorting. + * **When to use** + * + * Use to sort an array using a single `Order` comparator. + * + * **Details** + * + * Preserves `NonEmptyArray` in the return type. Use `sortWith` to sort by a + * derived key, or `sortBy` for multi-key sorting. * * **Example** (Sorting numbers) * @@ -3178,10 +4027,14 @@ export declare const sort: { /** * Sorts an array by the given `Order`, returning a new array. * - * - Does not mutate the input. - * - Preserves `NonEmptyArray` in the return type. - * - Use {@link sortWith} to sort by a derived key, or {@link sortBy} for - * multi-key sorting. + * **When to use** + * + * Use to sort an array using a single `Order` comparator. + * + * **Details** + * + * Preserves `NonEmptyArray` in the return type. Use `sortWith` to sort by a + * derived key, or `sortBy` for multi-key sorting. * * **Example** (Sorting numbers) * @@ -3203,8 +4056,14 @@ export declare const sort: { * Sorts an array by a derived key using a mapping function and an `Order` for * that key. * - * - Equivalent to `sort(Order.mapInput(order, f))` but more convenient. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to sort values by a derived key, such as a string length or + * object field, while keeping the original values. + * + * **Details** + * + * Equivalent to `sort(Order.mapInput(order, f))`, but more convenient. * * **Example** (Sorting strings by length) * @@ -3215,19 +4074,25 @@ export declare const sort: { * // ["b", "cc", "aaa"] * ``` * - * @see {@link sort} — sort by a direct `Order` - * @see {@link sortBy} — sort by multiple orders + * @see {@link sort} for sorting with an `Order` that compares the elements directly + * @see {@link sortBy} for sorting with multiple `Order`s applied in sequence * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const sortWith: { /** * Sorts an array by a derived key using a mapping function and an `Order` for * that key. * - * - Equivalent to `sort(Order.mapInput(order, f))` but more convenient. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to sort values by a derived key, such as a string length or + * object field, while keeping the original values. + * + * **Details** + * + * Equivalent to `sort(Order.mapInput(order, f))`, but more convenient. * * **Example** (Sorting strings by length) * @@ -3238,19 +4103,25 @@ export declare const sortWith: { * // ["b", "cc", "aaa"] * ``` * - * @see {@link sort} — sort by a direct `Order` - * @see {@link sortBy} — sort by multiple orders + * @see {@link sort} for sorting with an `Order` that compares the elements directly + * @see {@link sortBy} for sorting with multiple `Order`s applied in sequence * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ , B>(f: (a: ReadonlyArray.Infer) => B, order: Order.Order): (self: S) => ReadonlyArray.With>; /** * Sorts an array by a derived key using a mapping function and an `Order` for * that key. * - * - Equivalent to `sort(Order.mapInput(order, f))` but more convenient. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to sort values by a derived key, such as a string length or + * object field, while keeping the original values. + * + * **Details** + * + * Equivalent to `sort(Order.mapInput(order, f))`, but more convenient. * * **Example** (Sorting strings by length) * @@ -3261,19 +4132,25 @@ export declare const sortWith: { * // ["b", "cc", "aaa"] * ``` * - * @see {@link sort} — sort by a direct `Order` - * @see {@link sortBy} — sort by multiple orders + * @see {@link sort} for sorting with an `Order` that compares the elements directly + * @see {@link sortBy} for sorting with multiple `Order`s applied in sequence * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: NonEmptyReadonlyArray, f: (a: A) => B, O: Order.Order): NonEmptyArray; /** * Sorts an array by a derived key using a mapping function and an `Order` for * that key. * - * - Equivalent to `sort(Order.mapInput(order, f))` but more convenient. - * - Does not mutate the input. + * **When to use** + * + * Use when you need to sort values by a derived key, such as a string length or + * object field, while keeping the original values. + * + * **Details** + * + * Equivalent to `sort(Order.mapInput(order, f))`, but more convenient. * * **Example** (Sorting strings by length) * @@ -3284,11 +4161,11 @@ export declare const sortWith: { * // ["b", "cc", "aaa"] * ``` * - * @see {@link sort} — sort by a direct `Order` - * @see {@link sortBy} — sort by multiple orders + * @see {@link sort} for sorting with an `Order` that compares the elements directly + * @see {@link sortBy} for sorting with multiple `Order`s applied in sequence * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: Iterable, f: (a: A) => B, order: Order.Order): Array; }; @@ -3296,8 +4173,15 @@ export declare const sortWith: { * Sorts an array by multiple `Order`s applied in sequence: the first order is * used first; ties are broken by the second order, and so on. * - * - Data-last only (returns a function). - * - Preserves `NonEmptyArray` in the return type. + * **When to use** + * + * Use to sort by multiple criteria where later orders break ties from earlier + * ones. + * + * **Details** + * + * This is data-last only and returns a function. The return type preserves + * `NonEmptyArray`. * * **Example** (Multi-key sorting) * @@ -3332,7 +4216,13 @@ export declare const sortBy: >(...orders: ReadonlyArray< * Pairs elements from two iterables by position. If the iterables differ in * length, the extra elements from the longer one are discarded. * - * - Returns `NonEmptyArray` when both inputs are non-empty. + * **When to use** + * + * Use when you need simple pairs of corresponding elements from two iterables. + * + * **Details** + * + * Returns `NonEmptyArray` when both inputs are non-empty. * * **Example** (Zipping two arrays) * @@ -3353,7 +4243,13 @@ export declare const zip: { * Pairs elements from two iterables by position. If the iterables differ in * length, the extra elements from the longer one are discarded. * - * - Returns `NonEmptyArray` when both inputs are non-empty. + * **When to use** + * + * Use when you need simple pairs of corresponding elements from two iterables. + * + * **Details** + * + * Returns `NonEmptyArray` when both inputs are non-empty. * * **Example** (Zipping two arrays) * @@ -3374,7 +4270,13 @@ export declare const zip: { * Pairs elements from two iterables by position. If the iterables differ in * length, the extra elements from the longer one are discarded. * - * - Returns `NonEmptyArray` when both inputs are non-empty. + * **When to use** + * + * Use when you need simple pairs of corresponding elements from two iterables. + * + * **Details** + * + * Returns `NonEmptyArray` when both inputs are non-empty. * * **Example** (Zipping two arrays) * @@ -3395,7 +4297,13 @@ export declare const zip: { * Pairs elements from two iterables by position. If the iterables differ in * length, the extra elements from the longer one are discarded. * - * - Returns `NonEmptyArray` when both inputs are non-empty. + * **When to use** + * + * Use when you need simple pairs of corresponding elements from two iterables. + * + * **Details** + * + * Returns `NonEmptyArray` when both inputs are non-empty. * * **Example** (Zipping two arrays) * @@ -3416,7 +4324,13 @@ export declare const zip: { * Pairs elements from two iterables by position. If the iterables differ in * length, the extra elements from the longer one are discarded. * - * - Returns `NonEmptyArray` when both inputs are non-empty. + * **When to use** + * + * Use when you need simple pairs of corresponding elements from two iterables. + * + * **Details** + * + * Returns `NonEmptyArray` when both inputs are non-empty. * * **Example** (Zipping two arrays) * @@ -3438,6 +4352,11 @@ export declare const zip: { * Combines elements from two iterables pairwise using a function. If the * iterables differ in length, extra elements are discarded. * + * **When to use** + * + * Use when zipping two iterables in an array pipeline and each pair should + * become a computed array element instead of a tuple. + * * **Example** (Zipping with addition) * * ```ts @@ -3456,6 +4375,11 @@ export declare const zipWith: { * Combines elements from two iterables pairwise using a function. If the * iterables differ in length, extra elements are discarded. * + * **When to use** + * + * Use when zipping two iterables in an array pipeline and each pair should + * become a computed array element instead of a tuple. + * * **Example** (Zipping with addition) * * ```ts @@ -3474,6 +4398,11 @@ export declare const zipWith: { * Combines elements from two iterables pairwise using a function. If the * iterables differ in length, extra elements are discarded. * + * **When to use** + * + * Use when zipping two iterables in an array pipeline and each pair should + * become a computed array element instead of a tuple. + * * **Example** (Zipping with addition) * * ```ts @@ -3492,6 +4421,11 @@ export declare const zipWith: { * Combines elements from two iterables pairwise using a function. If the * iterables differ in length, extra elements are discarded. * + * **When to use** + * + * Use when zipping two iterables in an array pipeline and each pair should + * become a computed array element instead of a tuple. + * * **Example** (Zipping with addition) * * ```ts @@ -3510,6 +4444,11 @@ export declare const zipWith: { * Combines elements from two iterables pairwise using a function. If the * iterables differ in length, extra elements are discarded. * + * **When to use** + * + * Use when zipping two iterables in an array pipeline and each pair should + * become a computed array element instead of a tuple. + * * **Example** (Zipping with addition) * * ```ts @@ -3545,8 +4484,14 @@ export declare const unzip: >(self: S) = /** * Places a separator element between every pair of elements. * - * - Preserves `NonEmptyArray` in the return type. - * - An empty input produces an empty result. + * **When to use** + * + * Use to insert a separator between elements, for example when preparing data for display or concatenation. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Empty inputs produce an empty + * result. * * **Example** (Interspersing a separator) * @@ -3565,8 +4510,14 @@ export declare const intersperse: { /** * Places a separator element between every pair of elements. * - * - Preserves `NonEmptyArray` in the return type. - * - An empty input produces an empty result. + * **When to use** + * + * Use to insert a separator between elements, for example when preparing data for display or concatenation. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Empty inputs produce an empty + * result. * * **Example** (Interspersing a separator) * @@ -3585,8 +4536,14 @@ export declare const intersperse: { /** * Places a separator element between every pair of elements. * - * - Preserves `NonEmptyArray` in the return type. - * - An empty input produces an empty result. + * **When to use** + * + * Use to insert a separator between elements, for example when preparing data for display or concatenation. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Empty inputs produce an empty + * result. * * **Example** (Interspersing a separator) * @@ -3605,8 +4562,14 @@ export declare const intersperse: { /** * Places a separator element between every pair of elements. * - * - Preserves `NonEmptyArray` in the return type. - * - An empty input produces an empty result. + * **When to use** + * + * Use to insert a separator between elements, for example when preparing data for display or concatenation. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Empty inputs produce an empty + * result. * * **Example** (Interspersing a separator) * @@ -3627,6 +4590,10 @@ export declare const intersperse: { * Applies a function to the first element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use to transform the first element of a non-empty array while preserving the rest. + * * **Example** (Modifying the head) * * ```ts @@ -3639,13 +4606,17 @@ export declare const intersperse: { * @see {@link modifyLastNonEmpty} — modify the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ export declare const modifyHeadNonEmpty: { /** * Applies a function to the first element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use to transform the first element of a non-empty array while preserving the rest. + * * **Example** (Modifying the head) * * ```ts @@ -3658,13 +4629,17 @@ export declare const modifyHeadNonEmpty: { * @see {@link modifyLastNonEmpty} — modify the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (f: (a: A) => B): (self: NonEmptyReadonlyArray) => NonEmptyArray; /** * Applies a function to the first element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use to transform the first element of a non-empty array while preserving the rest. + * * **Example** (Modifying the head) * * ```ts @@ -3677,13 +4652,18 @@ export declare const modifyHeadNonEmpty: { * @see {@link modifyLastNonEmpty} — modify the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (self: NonEmptyReadonlyArray, f: (a: A) => B): NonEmptyArray; }; /** * Replaces the first element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current first element. + * * **Example** (Setting the head) * * ```ts @@ -3696,12 +4676,17 @@ export declare const modifyHeadNonEmpty: { * @see {@link setLastNonEmpty} — replace the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ export declare const setHeadNonEmpty: { /** * Replaces the first element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current first element. + * * **Example** (Setting the head) * * ```ts @@ -3714,12 +4699,17 @@ export declare const setHeadNonEmpty: { * @see {@link setLastNonEmpty} — replace the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (b: B): (self: NonEmptyReadonlyArray) => NonEmptyArray; /** * Replaces the first element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current first element. + * * **Example** (Setting the head) * * ```ts @@ -3732,7 +4722,7 @@ export declare const setHeadNonEmpty: { * @see {@link setLastNonEmpty} — replace the last element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (self: NonEmptyReadonlyArray, b: B): NonEmptyArray; }; @@ -3740,6 +4730,11 @@ export declare const setHeadNonEmpty: { * Applies a function to the last element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use when you already know the array is non-empty and the new last element + * depends on the current last element. + * * **Example** (Modifying the last element) * * ```ts @@ -3752,13 +4747,18 @@ export declare const setHeadNonEmpty: { * @see {@link modifyHeadNonEmpty} — modify the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ export declare const modifyLastNonEmpty: { /** * Applies a function to the last element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use when you already know the array is non-empty and the new last element + * depends on the current last element. + * * **Example** (Modifying the last element) * * ```ts @@ -3771,13 +4771,18 @@ export declare const modifyLastNonEmpty: { * @see {@link modifyHeadNonEmpty} — modify the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (f: (a: A) => B): (self: NonEmptyReadonlyArray) => NonEmptyArray; /** * Applies a function to the last element of a non-empty array, returning a * new array. * + * **When to use** + * + * Use when you already know the array is non-empty and the new last element + * depends on the current last element. + * * **Example** (Modifying the last element) * * ```ts @@ -3790,13 +4795,18 @@ export declare const modifyLastNonEmpty: { * @see {@link modifyHeadNonEmpty} — modify the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (self: NonEmptyReadonlyArray, f: (a: A) => B): NonEmptyArray; }; /** * Replaces the last element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current last element. + * * **Example** (Setting the last element) * * ```ts @@ -3809,12 +4819,17 @@ export declare const modifyLastNonEmpty: { * @see {@link setHeadNonEmpty} — replace the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ export declare const setLastNonEmpty: { /** * Replaces the last element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current last element. + * * **Example** (Setting the last element) * * ```ts @@ -3827,12 +4842,17 @@ export declare const setLastNonEmpty: { * @see {@link setHeadNonEmpty} — replace the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (b: B): (self: NonEmptyReadonlyArray) => NonEmptyArray; /** * Replaces the last element of a non-empty array with a new value. * + * **When to use** + * + * Use when you already know the array is non-empty and the replacement value + * does not depend on the current last element. + * * **Example** (Setting the last element) * * ```ts @@ -3845,16 +4865,24 @@ export declare const setLastNonEmpty: { * @see {@link setHeadNonEmpty} — replace the first element * * @category elements - * @since 2.0.0 + * @since 4.0.0 */ (self: NonEmptyReadonlyArray, b: B): NonEmptyArray; }; /** - * Rotates an array by `n` steps. Positive `n` rotates left (front elements - * move to the back). + * Transforms an array by rotating it `n` steps. Positive `n` rotates right; negative `n` + * rotates left. + * + * **When to use** + * + * Use when elements should wrap around the end of the array rather than being + * dropped. * - * - Preserves `NonEmptyArray` in the return type. - * - Returns a copy for empty arrays or `n === 0`. + * **Details** + * + * `n` is rounded to the nearest integer before rotating. The return type + * preserves `NonEmptyArray`. Empty arrays, or rotations normalized to `0`, + * return a copy. * * **Example** (Rotating elements) * @@ -3864,16 +4892,27 @@ export declare const setLastNonEmpty: { * console.log(Array.rotate(["a", "b", "c", "d"], 2)) // ["c", "d", "a", "b"] * ``` * + * @see {@link take} for taking a fixed number of elements from the start + * @see {@link drop} for dropping a fixed number of elements from the start + * * @category elements * @since 2.0.0 */ export declare const rotate: { /** - * Rotates an array by `n` steps. Positive `n` rotates left (front elements - * move to the back). + * Transforms an array by rotating it `n` steps. Positive `n` rotates right; negative `n` + * rotates left. + * + * **When to use** + * + * Use when elements should wrap around the end of the array rather than being + * dropped. * - * - Preserves `NonEmptyArray` in the return type. - * - Returns a copy for empty arrays or `n === 0`. + * **Details** + * + * `n` is rounded to the nearest integer before rotating. The return type + * preserves `NonEmptyArray`. Empty arrays, or rotations normalized to `0`, + * return a copy. * * **Example** (Rotating elements) * @@ -3883,16 +4922,27 @@ export declare const rotate: { * console.log(Array.rotate(["a", "b", "c", "d"], 2)) // ["c", "d", "a", "b"] * ``` * + * @see {@link take} for taking a fixed number of elements from the start + * @see {@link drop} for dropping a fixed number of elements from the start + * * @category elements * @since 2.0.0 */ (n: number): >(self: S) => ReadonlyArray.With>; /** - * Rotates an array by `n` steps. Positive `n` rotates left (front elements - * move to the back). + * Transforms an array by rotating it `n` steps. Positive `n` rotates right; negative `n` + * rotates left. + * + * **When to use** + * + * Use when elements should wrap around the end of the array rather than being + * dropped. * - * - Preserves `NonEmptyArray` in the return type. - * - Returns a copy for empty arrays or `n === 0`. + * **Details** + * + * `n` is rounded to the nearest integer before rotating. The return type + * preserves `NonEmptyArray`. Empty arrays, or rotations normalized to `0`, + * return a copy. * * **Example** (Rotating elements) * @@ -3902,16 +4952,27 @@ export declare const rotate: { * console.log(Array.rotate(["a", "b", "c", "d"], 2)) // ["c", "d", "a", "b"] * ``` * + * @see {@link take} for taking a fixed number of elements from the start + * @see {@link drop} for dropping a fixed number of elements from the start + * * @category elements * @since 2.0.0 */ (self: NonEmptyReadonlyArray, n: number): NonEmptyArray; /** - * Rotates an array by `n` steps. Positive `n` rotates left (front elements - * move to the back). + * Transforms an array by rotating it `n` steps. Positive `n` rotates right; negative `n` + * rotates left. + * + * **When to use** + * + * Use when elements should wrap around the end of the array rather than being + * dropped. * - * - Preserves `NonEmptyArray` in the return type. - * - Returns a copy for empty arrays or `n === 0`. + * **Details** + * + * `n` is rounded to the nearest integer before rotating. The return type + * preserves `NonEmptyArray`. Empty arrays, or rotations normalized to `0`, + * return a copy. * * **Example** (Rotating elements) * @@ -3921,6 +4982,9 @@ export declare const rotate: { * console.log(Array.rotate(["a", "b", "c", "d"], 2)) // ["c", "d", "a", "b"] * ``` * + * @see {@link take} for taking a fixed number of elements from the start + * @see {@link drop} for dropping a fixed number of elements from the start + * * @category elements * @since 2.0.0 */ @@ -3929,6 +4993,11 @@ export declare const rotate: { /** * Returns a membership-test function using a custom equivalence. * + * **When to use** + * + * Use when checking membership with caller-provided equality instead of + * `Equal.equivalence()`. + * * **Example** (Custom equality check) * * ```ts @@ -3938,7 +5007,7 @@ export declare const rotate: { * console.log(pipe([1, 2, 3, 4], containsNumber(3))) // true * ``` * - * @see {@link contains} — uses default `Equal.equivalence()` + * @see {@link contains} for the `Equal.equivalence()` variant * * @category elements * @since 2.0.0 @@ -3948,9 +5017,14 @@ export declare const containsWith: (isEquivalent: (self: A, that: A) => boole (self: Iterable, a: A): boolean; }; /** - * Tests whether an array contains a value, using `Equal.equivalence()` for + * Checks whether an array contains a value, using `Equal.equivalence()` for * comparison. * + * **When to use** + * + * Use to check whether an iterable contains a value using Effect's default + * equality instead of providing a comparison function. + * * **Example** (Checking membership) * * ```ts @@ -3966,9 +5040,14 @@ export declare const containsWith: (isEquivalent: (self: A, that: A) => boole */ export declare const contains: { /** - * Tests whether an array contains a value, using `Equal.equivalence()` for + * Checks whether an array contains a value, using `Equal.equivalence()` for * comparison. * + * **When to use** + * + * Use to check whether an iterable contains a value using Effect's default + * equality instead of providing a comparison function. + * * **Example** (Checking membership) * * ```ts @@ -3984,9 +5063,14 @@ export declare const contains: { */ (a: A): (self: Iterable) => boolean; /** - * Tests whether an array contains a value, using `Equal.equivalence()` for + * Checks whether an array contains a value, using `Equal.equivalence()` for * comparison. * + * **When to use** + * + * Use to check whether an iterable contains a value using Effect's default + * equality instead of providing a comparison function. + * * **Example** (Checking membership) * * ```ts @@ -4003,13 +5087,18 @@ export declare const contains: { (self: Iterable, a: A): boolean; }; /** - * Repeatedly applies a function that consumes a prefix of the array and - * produces a value plus the remaining elements, collecting the values. + * Applies a function repeatedly to consume prefixes of the array and collect + * the values it produces. + * + * **When to use** * - * - The function receives a `NonEmptyReadonlyArray` and returns - * `[value, rest]`. - * - Continues until the remaining array is empty. - * - Useful for custom splitting/grouping logic. + * Use when you need custom grouping logic where each step returns both a value + * and the remaining input. + * + * **Details** + * + * The function receives a `NonEmptyReadonlyArray` and returns `[value, rest]`. + * Processing continues until the remaining array is empty. * * **Example** (Chopping an array) * @@ -4031,13 +5120,18 @@ export declare const contains: { */ export declare const chop: { /** - * Repeatedly applies a function that consumes a prefix of the array and - * produces a value plus the remaining elements, collecting the values. + * Applies a function repeatedly to consume prefixes of the array and collect + * the values it produces. + * + * **When to use** + * + * Use when you need custom grouping logic where each step returns both a value + * and the remaining input. * - * - The function receives a `NonEmptyReadonlyArray` and returns - * `[value, rest]`. - * - Continues until the remaining array is empty. - * - Useful for custom splitting/grouping logic. + * **Details** + * + * The function receives a `NonEmptyReadonlyArray` and returns `[value, rest]`. + * Processing continues until the remaining array is empty. * * **Example** (Chopping an array) * @@ -4059,13 +5153,18 @@ export declare const chop: { */ , B>(f: (as: NonEmptyReadonlyArray>) => readonly [B, ReadonlyArray>]): (self: S) => ReadonlyArray.With>; /** - * Repeatedly applies a function that consumes a prefix of the array and - * produces a value plus the remaining elements, collecting the values. + * Applies a function repeatedly to consume prefixes of the array and collect + * the values it produces. + * + * **When to use** + * + * Use when you need custom grouping logic where each step returns both a value + * and the remaining input. + * + * **Details** * - * - The function receives a `NonEmptyReadonlyArray` and returns - * `[value, rest]`. - * - Continues until the remaining array is empty. - * - Useful for custom splitting/grouping logic. + * The function receives a `NonEmptyReadonlyArray` and returns `[value, rest]`. + * Processing continues until the remaining array is empty. * * **Example** (Chopping an array) * @@ -4087,13 +5186,18 @@ export declare const chop: { */ (self: NonEmptyReadonlyArray, f: (as: NonEmptyReadonlyArray) => readonly [B, ReadonlyArray]): NonEmptyArray; /** - * Repeatedly applies a function that consumes a prefix of the array and - * produces a value plus the remaining elements, collecting the values. + * Applies a function repeatedly to consume prefixes of the array and collect + * the values it produces. * - * - The function receives a `NonEmptyReadonlyArray` and returns - * `[value, rest]`. - * - Continues until the remaining array is empty. - * - Useful for custom splitting/grouping logic. + * **When to use** + * + * Use when you need custom grouping logic where each step returns both a value + * and the remaining input. + * + * **Details** + * + * The function receives a `NonEmptyReadonlyArray` and returns `[value, rest]`. + * Processing continues until the remaining array is empty. * * **Example** (Chopping an array) * @@ -4118,8 +5222,14 @@ export declare const chop: { /** * Splits an iterable into two arrays at the given index. * - * - `n` can be `0` (all elements in the second array). - * - `n` is floored to an integer. + * **When to use** + * + * Use to divide an array into a prefix and suffix at a specific position. + * + * **Details** + * + * `n` can be `0`, in which case all elements are placed in the second array. + * The index is floored to an integer. * * **Example** (Splitting at an index) * @@ -4139,8 +5249,14 @@ export declare const splitAt: { /** * Splits an iterable into two arrays at the given index. * - * - `n` can be `0` (all elements in the second array). - * - `n` is floored to an integer. + * **When to use** + * + * Use to divide an array into a prefix and suffix at a specific position. + * + * **Details** + * + * `n` can be `0`, in which case all elements are placed in the second array. + * The index is floored to an integer. * * **Example** (Splitting at an index) * @@ -4160,8 +5276,14 @@ export declare const splitAt: { /** * Splits an iterable into two arrays at the given index. * - * - `n` can be `0` (all elements in the second array). - * - `n` is floored to an integer. + * **When to use** + * + * Use to divide an array into a prefix and suffix at a specific position. + * + * **Details** + * + * `n` can be `0`, in which case all elements are placed in the second array. + * The index is floored to an integer. * * **Example** (Splitting at an index) * @@ -4183,6 +5305,11 @@ export declare const splitAt: { * Splits a non-empty array into two parts at the given index. The first part * is guaranteed to be non-empty (`n` is clamped to >= 1). * + * **When to use** + * + * Use when downstream code requires the left side of the split to contain at + * least one element. + * * **Example** (Splitting a non-empty array) * * ```ts @@ -4195,13 +5322,18 @@ export declare const splitAt: { * @see {@link splitAt} — for possibly-empty arrays * * @category splitting - * @since 2.0.0 + * @since 4.0.0 */ export declare const splitAtNonEmpty: { /** * Splits a non-empty array into two parts at the given index. The first part * is guaranteed to be non-empty (`n` is clamped to >= 1). * + * **When to use** + * + * Use when downstream code requires the left side of the split to contain at + * least one element. + * * **Example** (Splitting a non-empty array) * * ```ts @@ -4214,13 +5346,18 @@ export declare const splitAtNonEmpty: { * @see {@link splitAt} — for possibly-empty arrays * * @category splitting - * @since 2.0.0 + * @since 4.0.0 */ (n: number): (self: NonEmptyReadonlyArray) => [beforeIndex: NonEmptyArray, fromIndex: Array]; /** * Splits a non-empty array into two parts at the given index. The first part * is guaranteed to be non-empty (`n` is clamped to >= 1). * + * **When to use** + * + * Use when downstream code requires the left side of the split to contain at + * least one element. + * * **Example** (Splitting a non-empty array) * * ```ts @@ -4233,15 +5370,20 @@ export declare const splitAtNonEmpty: { * @see {@link splitAt} — for possibly-empty arrays * * @category splitting - * @since 2.0.0 + * @since 4.0.0 */ (self: NonEmptyReadonlyArray, n: number): [beforeIndex: NonEmptyArray, fromIndex: Array]; }; /** * Splits an iterable into `n` roughly equal-sized chunks. * - * - Uses `chunksOf(ceil(length / n))` internally. - * - The last chunk may be shorter. + * **When to use** + * + * Use to distribute elements across a fixed number of groups, such as when splitting work across threads. + * + * **Details** + * + * Uses `chunksOf(ceil(length / n))` internally. The last chunk may be shorter. * * **Example** (Splitting into groups) * @@ -4253,15 +5395,20 @@ export declare const splitAtNonEmpty: { * * @see {@link chunksOf} — split into fixed-size chunks * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ export declare const split: { /** * Splits an iterable into `n` roughly equal-sized chunks. * - * - Uses `chunksOf(ceil(length / n))` internally. - * - The last chunk may be shorter. + * **When to use** + * + * Use to distribute elements across a fixed number of groups, such as when splitting work across threads. + * + * **Details** + * + * Uses `chunksOf(ceil(length / n))` internally. The last chunk may be shorter. * * **Example** (Splitting into groups) * @@ -4273,15 +5420,20 @@ export declare const split: { * * @see {@link chunksOf} — split into fixed-size chunks * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (n: number): (self: Iterable) => Array>; /** * Splits an iterable into `n` roughly equal-sized chunks. * - * - Uses `chunksOf(ceil(length / n))` internally. - * - The last chunk may be shorter. + * **When to use** + * + * Use to distribute elements across a fixed number of groups, such as when splitting work across threads. + * + * **Details** + * + * Uses `chunksOf(ceil(length / n))` internally. The last chunk may be shorter. * * **Example** (Splitting into groups) * @@ -4293,8 +5445,8 @@ export declare const split: { * * @see {@link chunksOf} — split into fixed-size chunks * - * @since 2.0.0 * @category splitting + * @since 2.0.0 */ (self: Iterable, n: number): Array>; }; @@ -4302,6 +5454,11 @@ export declare const split: { * Splits an iterable at the first element matching the predicate. The matching * element is included in the second array. * + * **When to use** + * + * Use when you need to split an array at the first element that marks a + * condition boundary. + * * **Example** (Splitting at a condition) * * ```ts @@ -4321,6 +5478,11 @@ export declare const splitWhere: { * Splits an iterable at the first element matching the predicate. The matching * element is included in the second array. * + * **When to use** + * + * Use when you need to split an array at the first element that marks a + * condition boundary. + * * **Example** (Splitting at a condition) * * ```ts @@ -4340,6 +5502,11 @@ export declare const splitWhere: { * Splits an iterable at the first element matching the predicate. The matching * element is included in the second array. * + * **When to use** + * + * Use when you need to split an array at the first element that marks a + * condition boundary. + * * **Example** (Splitting at a condition) * * ```ts @@ -4359,8 +5526,15 @@ export declare const splitWhere: { /** * Creates a shallow copy of an array. * - * - Preserves `NonEmptyArray` in the return type. - * - Useful when you need a distinct reference (e.g. before mutating). + * **When to use** + * + * Use to create a distinct array reference for an existing array, for example + * before mutating the returned array. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Use this when you need a distinct + * reference, for example before mutating the returned array. * * **Example** (Copying an array) * @@ -4382,8 +5556,15 @@ export declare const copy: { /** * Creates a shallow copy of an array. * - * - Preserves `NonEmptyArray` in the return type. - * - Useful when you need a distinct reference (e.g. before mutating). + * **When to use** + * + * Use to create a distinct array reference for an existing array, for example + * before mutating the returned array. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Use this when you need a distinct + * reference, for example before mutating the returned array. * * **Example** (Copying an array) * @@ -4405,8 +5586,15 @@ export declare const copy: { /** * Creates a shallow copy of an array. * - * - Preserves `NonEmptyArray` in the return type. - * - Useful when you need a distinct reference (e.g. before mutating). + * **When to use** + * + * Use to create a distinct array reference for an existing array, for example + * before mutating the returned array. + * + * **Details** + * + * The return type preserves `NonEmptyArray`. Use this when you need a distinct + * reference, for example before mutating the returned array. * * **Example** (Copying an array) * @@ -4430,7 +5618,13 @@ export declare const copy: { * Pads or truncates an array to exactly `n` elements, filling with `fill` * if the array is shorter, or slicing if longer. * - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to ensure an array has a specific length, padding with a fill value or truncating as needed. + * + * **Details** + * + * Returns an empty array when `n <= 0`. * * **Example** (Padding an array) * @@ -4451,7 +5645,13 @@ export declare const pad: { * Pads or truncates an array to exactly `n` elements, filling with `fill` * if the array is shorter, or slicing if longer. * - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to ensure an array has a specific length, padding with a fill value or truncating as needed. + * + * **Details** + * + * Returns an empty array when `n <= 0`. * * **Example** (Padding an array) * @@ -4472,7 +5672,13 @@ export declare const pad: { * Pads or truncates an array to exactly `n` elements, filling with `fill` * if the array is shorter, or slicing if longer. * - * - Returns an empty array when `n <= 0`. + * **When to use** + * + * Use to ensure an array has a specific length, padding with a fill value or truncating as needed. + * + * **Details** + * + * Returns an empty array when `n <= 0`. * * **Example** (Padding an array) * @@ -4494,9 +5700,15 @@ export declare const pad: { * Splits an iterable into chunks of length `n`. The last chunk may be shorter * if `n` does not evenly divide the length. * - * - `chunksOf(n)([])` is `[]`, not `[[]]`. - * - Each chunk is a `NonEmptyArray`. - * - Preserves `NonEmptyArray` in the outer return type. + * **When to use** + * + * Use to divide an iterable into a new array of non-overlapping chunks with a + * maximum chunk size. + * + * **Details** + * + * `chunksOf(n)([])` is `[]`, not `[[]]`. Each chunk is a `NonEmptyArray`, and + * the outer return type preserves `NonEmptyArray`. * * **Example** (Chunking an array) * @@ -4517,9 +5729,15 @@ export declare const chunksOf: { * Splits an iterable into chunks of length `n`. The last chunk may be shorter * if `n` does not evenly divide the length. * - * - `chunksOf(n)([])` is `[]`, not `[[]]`. - * - Each chunk is a `NonEmptyArray`. - * - Preserves `NonEmptyArray` in the outer return type. + * **When to use** + * + * Use to divide an iterable into a new array of non-overlapping chunks with a + * maximum chunk size. + * + * **Details** + * + * `chunksOf(n)([])` is `[]`, not `[[]]`. Each chunk is a `NonEmptyArray`, and + * the outer return type preserves `NonEmptyArray`. * * **Example** (Chunking an array) * @@ -4540,9 +5758,15 @@ export declare const chunksOf: { * Splits an iterable into chunks of length `n`. The last chunk may be shorter * if `n` does not evenly divide the length. * - * - `chunksOf(n)([])` is `[]`, not `[[]]`. - * - Each chunk is a `NonEmptyArray`. - * - Preserves `NonEmptyArray` in the outer return type. + * **When to use** + * + * Use to divide an iterable into a new array of non-overlapping chunks with a + * maximum chunk size. + * + * **Details** + * + * `chunksOf(n)([])` is `[]`, not `[[]]`. Each chunk is a `NonEmptyArray`, and + * the outer return type preserves `NonEmptyArray`. * * **Example** (Chunking an array) * @@ -4563,9 +5787,15 @@ export declare const chunksOf: { * Splits an iterable into chunks of length `n`. The last chunk may be shorter * if `n` does not evenly divide the length. * - * - `chunksOf(n)([])` is `[]`, not `[[]]`. - * - Each chunk is a `NonEmptyArray`. - * - Preserves `NonEmptyArray` in the outer return type. + * **When to use** + * + * Use to divide an iterable into a new array of non-overlapping chunks with a + * maximum chunk size. + * + * **Details** + * + * `chunksOf(n)([])` is `[]`, not `[[]]`. Each chunk is a `NonEmptyArray`, and + * the outer return type preserves `NonEmptyArray`. * * **Example** (Chunking an array) * @@ -4586,8 +5816,14 @@ export declare const chunksOf: { /** * Creates overlapping sliding windows of size `n`. * - * - Returns an empty array if `n <= 0` or the array has fewer than `n` elements. - * - Each window is a tuple of exactly `n` elements. + * **When to use** + * + * Use to process sequences with a moving window, such as for computing running averages or detecting patterns. + * + * **Details** + * + * Returns an empty array if `n <= 0` or the array has fewer than `n` elements. + * Each window is a tuple of exactly `n` elements. * * **Example** (Sliding windows) * @@ -4607,8 +5843,14 @@ export declare const window: { /** * Creates overlapping sliding windows of size `n`. * - * - Returns an empty array if `n <= 0` or the array has fewer than `n` elements. - * - Each window is a tuple of exactly `n` elements. + * **When to use** + * + * Use to process sequences with a moving window, such as for computing running averages or detecting patterns. + * + * **Details** + * + * Returns an empty array if `n <= 0` or the array has fewer than `n` elements. + * Each window is a tuple of exactly `n` elements. * * **Example** (Sliding windows) * @@ -4628,8 +5870,14 @@ export declare const window: { /** * Creates overlapping sliding windows of size `n`. * - * - Returns an empty array if `n <= 0` or the array has fewer than `n` elements. - * - Each window is a tuple of exactly `n` elements. + * **When to use** + * + * Use to process sequences with a moving window, such as for computing running averages or detecting patterns. + * + * **Details** + * + * Returns an empty array if `n <= 0` or the array has fewer than `n` elements. + * Each window is a tuple of exactly `n` elements. * * **Example** (Sliding windows) * @@ -4650,8 +5898,15 @@ export declare const window: { /** * Groups consecutive equal elements using a custom equivalence function. * - * - Only groups **adjacent** elements — non-adjacent duplicates stay separate. - * - Requires a `NonEmptyReadonlyArray`. + * **When to use** + * + * Use when you already have a non-empty array arranged so matching elements are + * adjacent and need a custom equivalence function. + * + * **Details** + * + * Only adjacent elements are grouped. Non-adjacent duplicates stay separate. + * Requires a `NonEmptyReadonlyArray`. * * **Example** (Grouping consecutive equal elements) * @@ -4662,8 +5917,8 @@ export declare const window: { * // [["a", "a"], ["b", "b", "b"], ["c"], ["a"]] * ``` * - * @see {@link group} — uses default equality - * @see {@link groupBy} — group by a key function into a record + * @see {@link group} for grouping adjacent elements with `Equal.equivalence()` + * @see {@link groupBy} for grouping all elements into a record by key, regardless of adjacency * * @category grouping * @since 2.0.0 @@ -4672,8 +5927,15 @@ export declare const groupWith: { /** * Groups consecutive equal elements using a custom equivalence function. * - * - Only groups **adjacent** elements — non-adjacent duplicates stay separate. - * - Requires a `NonEmptyReadonlyArray`. + * **When to use** + * + * Use when you already have a non-empty array arranged so matching elements are + * adjacent and need a custom equivalence function. + * + * **Details** + * + * Only adjacent elements are grouped. Non-adjacent duplicates stay separate. + * Requires a `NonEmptyReadonlyArray`. * * **Example** (Grouping consecutive equal elements) * @@ -4684,8 +5946,8 @@ export declare const groupWith: { * // [["a", "a"], ["b", "b", "b"], ["c"], ["a"]] * ``` * - * @see {@link group} — uses default equality - * @see {@link groupBy} — group by a key function into a record + * @see {@link group} for grouping adjacent elements with `Equal.equivalence()` + * @see {@link groupBy} for grouping all elements into a record by key, regardless of adjacency * * @category grouping * @since 2.0.0 @@ -4694,8 +5956,15 @@ export declare const groupWith: { /** * Groups consecutive equal elements using a custom equivalence function. * - * - Only groups **adjacent** elements — non-adjacent duplicates stay separate. - * - Requires a `NonEmptyReadonlyArray`. + * **When to use** + * + * Use when you already have a non-empty array arranged so matching elements are + * adjacent and need a custom equivalence function. + * + * **Details** + * + * Only adjacent elements are grouped. Non-adjacent duplicates stay separate. + * Requires a `NonEmptyReadonlyArray`. * * **Example** (Grouping consecutive equal elements) * @@ -4706,8 +5975,8 @@ export declare const groupWith: { * // [["a", "a"], ["b", "b", "b"], ["c"], ["a"]] * ``` * - * @see {@link group} — uses default equality - * @see {@link groupBy} — group by a key function into a record + * @see {@link group} for grouping adjacent elements with `Equal.equivalence()` + * @see {@link groupBy} for grouping all elements into a record by key, regardless of adjacency * * @category grouping * @since 2.0.0 @@ -4717,7 +5986,14 @@ export declare const groupWith: { /** * Groups consecutive equal elements using `Equal.equivalence()`. * - * - Only groups **adjacent** elements. + * **When to use** + * + * Use when you already have adjacent equal values and Effect's default equality + * is the right comparison. + * + * **Details** + * + * Only adjacent elements are grouped. * * **Example** (Grouping adjacent equal elements) * @@ -4738,9 +6014,14 @@ export declare const group: (self: NonEmptyReadonlyArray) => NonEmptyArray * Groups elements into a record by a key-returning function. Each key maps * to a `NonEmptyArray` of elements that produced that key. * - * - Unlike {@link group}/{@link groupWith}, elements do not need to be - * adjacent to be grouped together. - * - Key function must return a `string` or `symbol`. + * **When to use** + * + * Use to build buckets of elements indexed by a computed string or symbol key. + * + * **Details** + * + * Unlike `group` and `groupWith`, elements do not need to be adjacent to be + * grouped together. The key function must return a `string` or `symbol`. * * **Example** (Grouping by a property) * @@ -4769,9 +6050,14 @@ export declare const groupBy: { * Groups elements into a record by a key-returning function. Each key maps * to a `NonEmptyArray` of elements that produced that key. * - * - Unlike {@link group}/{@link groupWith}, elements do not need to be - * adjacent to be grouped together. - * - Key function must return a `string` or `symbol`. + * **When to use** + * + * Use to build buckets of elements indexed by a computed string or symbol key. + * + * **Details** + * + * Unlike `group` and `groupWith`, elements do not need to be adjacent to be + * grouped together. The key function must return a `string` or `symbol`. * * **Example** (Grouping by a property) * @@ -4800,9 +6086,14 @@ export declare const groupBy: { * Groups elements into a record by a key-returning function. Each key maps * to a `NonEmptyArray` of elements that produced that key. * - * - Unlike {@link group}/{@link groupWith}, elements do not need to be - * adjacent to be grouped together. - * - Key function must return a `string` or `symbol`. + * **When to use** + * + * Use to build buckets of elements indexed by a computed string or symbol key. + * + * **Details** + * + * Unlike `group` and `groupWith`, elements do not need to be adjacent to be + * grouped together. The key function must return a `string` or `symbol`. * * **Example** (Grouping by a property) * @@ -4832,6 +6123,11 @@ export declare const groupBy: { * Computes the union of two arrays using a custom equivalence, removing * duplicates. * + * **When to use** + * + * Use when you need the union of two arrays but duplicate detection must use a + * custom equivalence instead of the default `Equal.equivalence()`. + * * **Example** (Union with custom equality) * * ```ts @@ -4840,9 +6136,9 @@ export declare const groupBy: { * console.log(Array.unionWith([1, 2], [2, 3], (a, b) => a === b)) // [1, 2, 3] * ``` * - * @see {@link union} — uses default equality - * @see {@link intersection} — elements in both arrays - * @see {@link difference} — elements only in the first array + * @see {@link union} for the `Equal.equivalence()` variant + * @see {@link intersectionWith} for keeping elements present in both arrays + * @see {@link differenceWith} for keeping elements present only in the first array * * @category elements * @since 2.0.0 @@ -4852,6 +6148,11 @@ export declare const unionWith: { * Computes the union of two arrays using a custom equivalence, removing * duplicates. * + * **When to use** + * + * Use when you need the union of two arrays but duplicate detection must use a + * custom equivalence instead of the default `Equal.equivalence()`. + * * **Example** (Union with custom equality) * * ```ts @@ -4860,9 +6161,9 @@ export declare const unionWith: { * console.log(Array.unionWith([1, 2], [2, 3], (a, b) => a === b)) // [1, 2, 3] * ``` * - * @see {@link union} — uses default equality - * @see {@link intersection} — elements in both arrays - * @see {@link difference} — elements only in the first array + * @see {@link union} for the `Equal.equivalence()` variant + * @see {@link intersectionWith} for keeping elements present in both arrays + * @see {@link differenceWith} for keeping elements present only in the first array * * @category elements * @since 2.0.0 @@ -4872,6 +6173,11 @@ export declare const unionWith: { * Computes the union of two arrays using a custom equivalence, removing * duplicates. * + * **When to use** + * + * Use when you need the union of two arrays but duplicate detection must use a + * custom equivalence instead of the default `Equal.equivalence()`. + * * **Example** (Union with custom equality) * * ```ts @@ -4880,9 +6186,9 @@ export declare const unionWith: { * console.log(Array.unionWith([1, 2], [2, 3], (a, b) => a === b)) // [1, 2, 3] * ``` * - * @see {@link union} — uses default equality - * @see {@link intersection} — elements in both arrays - * @see {@link difference} — elements only in the first array + * @see {@link union} for the `Equal.equivalence()` variant + * @see {@link intersectionWith} for keeping elements present in both arrays + * @see {@link differenceWith} for keeping elements present only in the first array * * @category elements * @since 2.0.0 @@ -4892,6 +6198,11 @@ export declare const unionWith: { * Computes the union of two arrays using a custom equivalence, removing * duplicates. * + * **When to use** + * + * Use when you need the union of two arrays but duplicate detection must use a + * custom equivalence instead of the default `Equal.equivalence()`. + * * **Example** (Union with custom equality) * * ```ts @@ -4900,9 +6211,9 @@ export declare const unionWith: { * console.log(Array.unionWith([1, 2], [2, 3], (a, b) => a === b)) // [1, 2, 3] * ``` * - * @see {@link union} — uses default equality - * @see {@link intersection} — elements in both arrays - * @see {@link difference} — elements only in the first array + * @see {@link union} for the `Equal.equivalence()` variant + * @see {@link intersectionWith} for keeping elements present in both arrays + * @see {@link differenceWith} for keeping elements present only in the first array * * @category elements * @since 2.0.0 @@ -4912,6 +6223,11 @@ export declare const unionWith: { * Computes the union of two arrays using a custom equivalence, removing * duplicates. * + * **When to use** + * + * Use when you need the union of two arrays but duplicate detection must use a + * custom equivalence instead of the default `Equal.equivalence()`. + * * **Example** (Union with custom equality) * * ```ts @@ -4920,9 +6236,9 @@ export declare const unionWith: { * console.log(Array.unionWith([1, 2], [2, 3], (a, b) => a === b)) // [1, 2, 3] * ``` * - * @see {@link union} — uses default equality - * @see {@link intersection} — elements in both arrays - * @see {@link difference} — elements only in the first array + * @see {@link union} for the `Equal.equivalence()` variant + * @see {@link intersectionWith} for keeping elements present in both arrays + * @see {@link differenceWith} for keeping elements present only in the first array * * @category elements * @since 2.0.0 @@ -5034,6 +6350,11 @@ export declare const union: { * Computes the intersection of two arrays using a custom equivalence. Order is * determined by the first array. * + * **When to use** + * + * Use when you need to keep only values present in both arrays and equality + * must be defined by a custom comparator, such as matching objects by id. + * * **Example** (Intersection with custom equality) * * ```ts @@ -5045,9 +6366,9 @@ export declare const union: { * console.log(Array.intersectionWith(isEquivalent)(array2)(array1)) // [{ id: 1 }, { id: 3 }] * ``` * - * @see {@link intersection} — uses default equality - * @see {@link union} — elements in either array - * @see {@link difference} — elements only in the first array + * @see {@link intersection} for the `Equal.equivalence()` variant + * @see {@link unionWith} for keeping values from either array with custom equality + * @see {@link differenceWith} for keeping values only from the first array with custom equality * * @category elements * @since 2.0.0 @@ -5060,6 +6381,11 @@ export declare const intersectionWith: (isEquivalent: (self: A, that: A) => b * Computes the intersection of two arrays using `Equal.equivalence()`. Order is * determined by the first array. * + * **When to use** + * + * Use when Effect equality is the right membership test and you want to keep + * values present in both inputs while preserving the first input's order. + * * **Example** (Array intersection) * * ```ts @@ -5080,6 +6406,11 @@ export declare const intersection: { * Computes the intersection of two arrays using `Equal.equivalence()`. Order is * determined by the first array. * + * **When to use** + * + * Use when Effect equality is the right membership test and you want to keep + * values present in both inputs while preserving the first input's order. + * * **Example** (Array intersection) * * ```ts @@ -5100,6 +6431,11 @@ export declare const intersection: { * Computes the intersection of two arrays using `Equal.equivalence()`. Order is * determined by the first array. * + * **When to use** + * + * Use when Effect equality is the right membership test and you want to keep + * values present in both inputs while preserving the first input's order. + * * **Example** (Array intersection) * * ```ts @@ -5121,6 +6457,11 @@ export declare const intersection: { * Computes elements in the first array that are not in the second, using a * custom equivalence. * + * **When to use** + * + * Use when you need to keep only values from the first array and equality must + * be defined by a custom comparator, such as matching objects by id. + * * **Example** (Difference with custom equality) * * ```ts @@ -5130,9 +6471,9 @@ export declare const intersection: { * console.log(diff) // [1] * ``` * - * @see {@link difference} — uses default equality - * @see {@link union} — elements in either array - * @see {@link intersection} — elements in both arrays + * @see {@link difference} for the `Equal.equivalence()` variant + * @see {@link unionWith} for keeping values from either array with custom equality + * @see {@link intersectionWith} for keeping values present in both arrays with custom equality * * @category elements * @since 2.0.0 @@ -5145,6 +6486,11 @@ export declare const differenceWith: (isEquivalent: (self: A, that: A) => boo * Computes elements in the first array that are not in the second, using * `Equal.equivalence()`. * + * **When to use** + * + * Use when you need to keep values from the first array that are absent from + * the second and the default `Equal.equivalence()` comparison is appropriate. + * * **Example** (Array difference) * * ```ts @@ -5165,6 +6511,11 @@ export declare const difference: { * Computes elements in the first array that are not in the second, using * `Equal.equivalence()`. * + * **When to use** + * + * Use when you need to keep values from the first array that are absent from + * the second and the default `Equal.equivalence()` comparison is appropriate. + * * **Example** (Array difference) * * ```ts @@ -5185,6 +6536,11 @@ export declare const difference: { * Computes elements in the first array that are not in the second, using * `Equal.equivalence()`. * + * **When to use** + * + * Use when you need to keep values from the first array that are absent from + * the second and the default `Equal.equivalence()` comparison is appropriate. + * * **Example** (Array difference) * * ```ts @@ -5205,6 +6561,10 @@ export declare const difference: { /** * Creates an empty array. * + * **When to use** + * + * Use to create a typed empty array without allocating placeholder elements. + * * **Example** (Creating an empty array) * * ```ts @@ -5243,14 +6603,14 @@ export declare const of: (a: A) => NonEmptyArray; * Utility types for working with `ReadonlyArray` at the type level. Use these * to infer element types, preserve non-emptiness, and flatten nested arrays. * - * @category types * @since 2.0.0 */ export declare namespace ReadonlyArray { /** * Infers the element type of an iterable. * - * @example + * **Example** (Inferring an element type) + * * ```ts * import type { Array } from "effect" * @@ -5265,7 +6625,8 @@ export declare namespace ReadonlyArray { /** * Constructs an array type preserving non-emptiness. * - * @example + * **Example** (Preserving non-emptiness) + * * ```ts * import type { Array } from "effect" * @@ -5280,7 +6641,8 @@ export declare namespace ReadonlyArray { /** * Creates a non-empty array if either input is non-empty. * - * @example + * **Example** (Preserving non-emptiness from either input) + * * ```ts * import type { Array } from "effect" * @@ -5299,7 +6661,8 @@ export declare namespace ReadonlyArray { /** * Creates a non-empty array only if both inputs are non-empty. * - * @example + * **Example** (Preserving non-emptiness from both inputs) + * * ```ts * import type { Array } from "effect" * @@ -5318,7 +6681,8 @@ export declare namespace ReadonlyArray { /** * Flattens a nested array type. * - * @example + * **Example** (Flattening nested array types) + * * ```ts * import type { Array } from "effect" * @@ -5335,8 +6699,14 @@ export declare namespace ReadonlyArray { /** * Transforms each element using a function, returning a new array. * - * - The function receives `(element, index)`. - * - Preserves `NonEmptyArray` in the return type. + * **When to use** + * + * Use to transform each element independently while preserving the array shape. + * + * **Details** + * + * The function receives `(element, index)`. The return type preserves + * `NonEmptyArray`. * * **Example** (Doubling values) * @@ -5355,8 +6725,14 @@ export declare const map: { /** * Transforms each element using a function, returning a new array. * - * - The function receives `(element, index)`. - * - Preserves `NonEmptyArray` in the return type. + * **When to use** + * + * Use to transform each element independently while preserving the array shape. + * + * **Details** + * + * The function receives `(element, index)`. The return type preserves + * `NonEmptyArray`. * * **Example** (Doubling values) * @@ -5375,8 +6751,14 @@ export declare const map: { /** * Transforms each element using a function, returning a new array. * - * - The function receives `(element, index)`. - * - Preserves `NonEmptyArray` in the return type. + * **When to use** + * + * Use to transform each element independently while preserving the array shape. + * + * **Details** + * + * The function receives `(element, index)`. The return type preserves + * `NonEmptyArray`. * * **Example** (Doubling values) * @@ -5396,8 +6778,15 @@ export declare const map: { /** * Maps each element to an array and flattens the results into a single array. * - * - The function receives `(element, index)`. - * - Returns `NonEmptyArray` when both input and mapped arrays are non-empty. + * **When to use** + * + * Use to map each array element to zero or more values and concatenate the + * results in one pass. + * + * **Details** + * + * The function receives `(element, index)`. This returns `NonEmptyArray` when + * both the input and mapped arrays are non-empty. * * **Example** (FlatMapping an array) * @@ -5417,8 +6806,15 @@ export declare const flatMap: { /** * Maps each element to an array and flattens the results into a single array. * - * - The function receives `(element, index)`. - * - Returns `NonEmptyArray` when both input and mapped arrays are non-empty. + * **When to use** + * + * Use to map each array element to zero or more values and concatenate the + * results in one pass. + * + * **Details** + * + * The function receives `(element, index)`. This returns `NonEmptyArray` when + * both the input and mapped arrays are non-empty. * * **Example** (FlatMapping an array) * @@ -5438,8 +6834,15 @@ export declare const flatMap: { /** * Maps each element to an array and flattens the results into a single array. * - * - The function receives `(element, index)`. - * - Returns `NonEmptyArray` when both input and mapped arrays are non-empty. + * **When to use** + * + * Use to map each array element to zero or more values and concatenate the + * results in one pass. + * + * **Details** + * + * The function receives `(element, index)`. This returns `NonEmptyArray` when + * both the input and mapped arrays are non-empty. * * **Example** (FlatMapping an array) * @@ -5459,8 +6862,15 @@ export declare const flatMap: { /** * Maps each element to an array and flattens the results into a single array. * - * - The function receives `(element, index)`. - * - Returns `NonEmptyArray` when both input and mapped arrays are non-empty. + * **When to use** + * + * Use to map each array element to zero or more values and concatenate the + * results in one pass. + * + * **Details** + * + * The function receives `(element, index)`. This returns `NonEmptyArray` when + * both the input and mapped arrays are non-empty. * * **Example** (FlatMapping an array) * @@ -5481,6 +6891,11 @@ export declare const flatMap: { /** * Flattens a nested array of arrays into a single array. * + * **When to use** + * + * Use to collapse one level of nested arrays when no per-element mapping is + * needed. + * * **Example** (Flattening nested arrays) * * ```ts @@ -5498,6 +6913,11 @@ export declare const flatten: > /** * Extracts all `Some` values from an iterable of `Option`s, discarding `None`s. * + * **When to use** + * + * Use to collect only present values from an iterable of `Option` values while + * discarding `None` values. + * * **Example** (Extracting Some values) * * ```ts @@ -5517,6 +6937,11 @@ export declare const getSomes: >, X = any>(s * Extracts all failure values from an iterable of `Result`s, discarding * successes. * + * **When to use** + * + * Use when you can drop the success channel and only need the failure + * payloads, not the original result wrappers. + * * **Example** (Extracting failures) * * ```ts @@ -5530,13 +6955,18 @@ export declare const getSomes: >, X = any>(s * @see {@link separate} — split into failures and successes * * @category filtering - * @since 2.0.0 + * @since 4.0.0 */ export declare const getFailures: >>(self: T) => Array>>; /** * Extracts all success values from an iterable of `Result`s, discarding * failures. * + * **When to use** + * + * Use when you can drop the failure channel and only need the success + * payloads, not the original result wrappers. + * * **Example** (Extracting successes) * * ```ts @@ -5550,14 +6980,20 @@ export declare const getFailures: >>( * @see {@link separate} — split into failures and successes * * @category filtering - * @since 2.0.0 + * @since 4.0.0 */ export declare const getSuccesses: >>(self: T) => Array>>; /** * Keeps transformed values for elements where a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Failures are discarded. + * **When to use** + * + * Use to filter an iterable with a `Result`-returning transformation while + * discarding failures. + * + * **Details** + * + * The filter receives `(element, index)`. Failures are discarded. * * **Example** (Filter and transform) * @@ -5569,16 +7005,23 @@ export declare const getSuccesses: >> * ``` * * @see {@link filter} — keep original elements matching a predicate + * @see {@link partition} for keeping both failures and successes * * @category filtering - * @since 4.0.0 + * @since 2.0.0 */ export declare const filterMap: { /** * Keeps transformed values for elements where a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Failures are discarded. + * **When to use** + * + * Use to filter an iterable with a `Result`-returning transformation while + * discarding failures. + * + * **Details** + * + * The filter receives `(element, index)`. Failures are discarded. * * **Example** (Filter and transform) * @@ -5590,16 +7033,23 @@ export declare const filterMap: { * ``` * * @see {@link filter} — keep original elements matching a predicate + * @see {@link partition} for keeping both failures and successes * * @category filtering - * @since 4.0.0 + * @since 2.0.0 */ (f: (input: NoInfer, i: number) => Result.Result): (self: Iterable) => Array; /** * Keeps transformed values for elements where a `Filter` succeeds. * - * - The filter receives `(element, index)`. - * - Failures are discarded. + * **When to use** + * + * Use to filter an iterable with a `Result`-returning transformation while + * discarding failures. + * + * **Details** + * + * The filter receives `(element, index)`. Failures are discarded. * * **Example** (Filter and transform) * @@ -5611,17 +7061,25 @@ export declare const filterMap: { * ``` * * @see {@link filter} — keep original elements matching a predicate + * @see {@link partition} for keeping both failures and successes * * @category filtering - * @since 4.0.0 + * @since 2.0.0 */ (self: Iterable, f: (input: A, i: number) => Result.Result): Array; }; /** * Keeps only elements satisfying a predicate (or refinement). * - * - The predicate receives `(element, index)`. - * - Supports refinements for type narrowing. + * **When to use** + * + * Use to filter an iterable into a new array of original elements that satisfy + * a boolean predicate or refinement. + * + * **Details** + * + * The predicate receives `(element, index)`. Refinements are supported for type + * narrowing. * * **Example** (Filtering even numbers) * @@ -5632,6 +7090,7 @@ export declare const filterMap: { * ``` * * @see {@link partition} — split into matching and non-matching + * @see {@link filterMap} for transforming while filtering * * @category filtering * @since 2.0.0 @@ -5640,8 +7099,15 @@ export declare const filter: { /** * Keeps only elements satisfying a predicate (or refinement). * - * - The predicate receives `(element, index)`. - * - Supports refinements for type narrowing. + * **When to use** + * + * Use to filter an iterable into a new array of original elements that satisfy + * a boolean predicate or refinement. + * + * **Details** + * + * The predicate receives `(element, index)`. Refinements are supported for type + * narrowing. * * **Example** (Filtering even numbers) * @@ -5652,6 +7118,7 @@ export declare const filter: { * ``` * * @see {@link partition} — split into matching and non-matching + * @see {@link filterMap} for transforming while filtering * * @category filtering * @since 2.0.0 @@ -5660,8 +7127,15 @@ export declare const filter: { /** * Keeps only elements satisfying a predicate (or refinement). * - * - The predicate receives `(element, index)`. - * - Supports refinements for type narrowing. + * **When to use** + * + * Use to filter an iterable into a new array of original elements that satisfy + * a boolean predicate or refinement. + * + * **Details** + * + * The predicate receives `(element, index)`. Refinements are supported for type + * narrowing. * * **Example** (Filtering even numbers) * @@ -5672,6 +7146,7 @@ export declare const filter: { * ``` * * @see {@link partition} — split into matching and non-matching + * @see {@link filterMap} for transforming while filtering * * @category filtering * @since 2.0.0 @@ -5680,8 +7155,15 @@ export declare const filter: { /** * Keeps only elements satisfying a predicate (or refinement). * - * - The predicate receives `(element, index)`. - * - Supports refinements for type narrowing. + * **When to use** + * + * Use to filter an iterable into a new array of original elements that satisfy + * a boolean predicate or refinement. + * + * **Details** + * + * The predicate receives `(element, index)`. Refinements are supported for type + * narrowing. * * **Example** (Filtering even numbers) * @@ -5692,6 +7174,7 @@ export declare const filter: { * ``` * * @see {@link partition} — split into matching and non-matching + * @see {@link filterMap} for transforming while filtering * * @category filtering * @since 2.0.0 @@ -5700,8 +7183,15 @@ export declare const filter: { /** * Keeps only elements satisfying a predicate (or refinement). * - * - The predicate receives `(element, index)`. - * - Supports refinements for type narrowing. + * **When to use** + * + * Use to filter an iterable into a new array of original elements that satisfy + * a boolean predicate or refinement. + * + * **Details** + * + * The predicate receives `(element, index)`. Refinements are supported for type + * narrowing. * * **Example** (Filtering even numbers) * @@ -5712,6 +7202,7 @@ export declare const filter: { * ``` * * @see {@link partition} — split into matching and non-matching + * @see {@link filterMap} for transforming while filtering * * @category filtering * @since 2.0.0 @@ -5721,8 +7212,14 @@ export declare const filter: { /** * Splits an iterable using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **When to use** + * + * Use to partition an iterable by evaluating each element with a + * `Result`-returning filter and keeping both failure and success values. + * + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. * * **Example** (Partitioning with a filter) * @@ -5736,7 +7233,8 @@ export declare const filter: { * ``` * * @see {@link filter} — keep only matching elements - * @see {@link partitionMap} — partition using a Result-returning function + * @see {@link filterMap} for discarding failures + * @see {@link separate} — split an iterable of `Result` values * * @category filtering * @since 2.0.0 @@ -5745,8 +7243,14 @@ export declare const partition: { /** * Splits an iterable using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **When to use** + * + * Use to partition an iterable by evaluating each element with a + * `Result`-returning filter and keeping both failure and success values. + * + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. * * **Example** (Partitioning with a filter) * @@ -5760,7 +7264,8 @@ export declare const partition: { * ``` * * @see {@link filter} — keep only matching elements - * @see {@link partitionMap} — partition using a Result-returning function + * @see {@link filterMap} for discarding failures + * @see {@link separate} — split an iterable of `Result` values * * @category filtering * @since 2.0.0 @@ -5769,8 +7274,14 @@ export declare const partition: { /** * Splits an iterable using a `Filter` into failures and successes. * - * - Returns `[excluded, satisfying]`. - * - The filter receives `(element, index)`. + * **When to use** + * + * Use to partition an iterable by evaluating each element with a + * `Result`-returning filter and keeping both failure and success values. + * + * **Details** + * + * Returns `[excluded, satisfying]`. The filter receives `(element, index)`. * * **Example** (Partitioning with a filter) * @@ -5784,7 +7295,8 @@ export declare const partition: { * ``` * * @see {@link filter} — keep only matching elements - * @see {@link partitionMap} — partition using a Result-returning function + * @see {@link filterMap} for discarding failures + * @see {@link separate} — split an iterable of `Result` values * * @category filtering * @since 2.0.0 @@ -5792,9 +7304,16 @@ export declare const partition: { (self: Iterable, f: (input: A, i: number) => Result.Result): [excluded: Array, satisfying: Array]; }; /** - * Separates an iterable of `Result`s into two arrays: failures and successes. + * Separates an iterable of `Result`s into failure values and success values. + * + * **When to use** + * + * Use to split an iterable of `Result` values into failure and success arrays. * - * - Equivalent to `partitionMap(identity)`. + * **Details** + * + * Returns `[failures, successes]`. This is equivalent to + * `partition(identity)`. * * **Example** (Separating Results) * @@ -5810,6 +7329,7 @@ export declare const partition: { * * @see {@link getFailures} — extract only failures * @see {@link getSuccesses} — extract only successes + * @see {@link partition} for computing `Result` values while splitting * * @category filtering * @since 2.0.0 @@ -5821,7 +7341,13 @@ export declare const separate: >>(sel /** * Folds an iterable from left to right into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use to combine all elements into one accumulated value from left to right. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Summing an array) * @@ -5841,7 +7367,13 @@ export declare const reduce: { /** * Folds an iterable from left to right into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use to combine all elements into one accumulated value from left to right. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Summing an array) * @@ -5861,7 +7393,13 @@ export declare const reduce: { /** * Folds an iterable from left to right into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use to combine all elements into one accumulated value from left to right. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Summing an array) * @@ -5882,7 +7420,13 @@ export declare const reduce: { /** * Folds an iterable from right to left into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use when you need to fold values from right to left. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Right-to-left fold) * @@ -5902,7 +7446,13 @@ export declare const reduceRight: { /** * Folds an iterable from right to left into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use when you need to fold values from right to left. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Right-to-left fold) * @@ -5922,7 +7472,13 @@ export declare const reduceRight: { /** * Folds an iterable from right to left into a single value. * - * - The function receives `(accumulator, element, index)`. + * **When to use** + * + * Use when you need to fold values from right to left. + * + * **Details** + * + * The function receives `(accumulator, element, index)`. * * **Example** (Right-to-left fold) * @@ -5988,6 +7544,11 @@ export declare const liftPredicate: { * Lifts an `Option`-returning function into one that returns an array: * `Some(a)` becomes `[a]`, `None` becomes `[]`. * + * **When to use** + * + * Use when an optional parser or lookup should participate in array pipelines + * as zero-or-one results. + * * **Example** (Lifting an Option function) * * ```ts @@ -6012,6 +7573,10 @@ export declare const liftOption: , B>(f: (...a: A) => O * Converts a nullable value to an array: `null`/`undefined` becomes `[]`, * anything else becomes `[value]`. * + * **When to use** + * + * Use to treat a nullable single value as zero or one array element. + * * **Example** (Nullable to array) * * ```ts @@ -6025,8 +7590,8 @@ export declare const liftOption: , B>(f: (...a: A) => O * @see {@link liftNullishOr} — lift a nullable-returning function * @see {@link fromOption} — convert from Option * - * @category conversions - * @since 2.0.0 + * @category converting + * @since 4.0.0 */ export declare const fromNullishOr: (a: A) => Array>; /** @@ -6050,13 +7615,18 @@ export declare const fromNullishOr: (a: A) => Array>; * @see {@link liftOption} — lift an Option-returning function * * @category lifting - * @since 2.0.0 + * @since 4.0.0 */ export declare const liftNullishOr: , B>(f: (...a: A) => B) => (...a: A) => Array>; /** * Maps each element with a nullable-returning function, keeping only non-null / * non-undefined results. * + * **When to use** + * + * Use when you need to map and filter in one step, where the mapper can return + * `null` or `undefined` to skip elements. + * * **Example** (FlatMapping with nullable) * * ```ts @@ -6066,14 +7636,22 @@ export declare const liftNullishOr: , B>(f: (...a: A) = * // [1, 3] * ``` * + * @see {@link flatMap} for mapping each element to an array and flattening + * @see {@link fromNullishOr} for converting a single nullable value to an array + * * @category sequencing - * @since 2.0.0 + * @since 4.0.0 */ export declare const flatMapNullishOr: { /** * Maps each element with a nullable-returning function, keeping only non-null / * non-undefined results. * + * **When to use** + * + * Use when you need to map and filter in one step, where the mapper can return + * `null` or `undefined` to skip elements. + * * **Example** (FlatMapping with nullable) * * ```ts @@ -6083,14 +7661,22 @@ export declare const flatMapNullishOr: { * // [1, 3] * ``` * + * @see {@link flatMap} for mapping each element to an array and flattening + * @see {@link fromNullishOr} for converting a single nullable value to an array + * * @category sequencing - * @since 2.0.0 + * @since 4.0.0 */ (f: (a: A) => B): (self: ReadonlyArray) => Array>; /** * Maps each element with a nullable-returning function, keeping only non-null / * non-undefined results. * + * **When to use** + * + * Use when you need to map and filter in one step, where the mapper can return + * `null` or `undefined` to skip elements. + * * **Example** (FlatMapping with nullable) * * ```ts @@ -6100,8 +7686,11 @@ export declare const flatMapNullishOr: { * // [1, 3] * ``` * + * @see {@link flatMap} for mapping each element to an array and flattening + * @see {@link fromNullishOr} for converting a single nullable value to an array + * * @category sequencing - * @since 2.0.0 + * @since 4.0.0 */ (self: ReadonlyArray, f: (a: A) => B): Array>; }; @@ -6109,6 +7698,11 @@ export declare const flatMapNullishOr: { * Lifts a `Result`-returning function into one that returns an array: failures * produce `[]`, successes produce `[value]`. * + * **When to use** + * + * Use when a fallible parser or lookup should participate in array pipelines as + * zero-or-one results and the failure value should be discarded. + * * **Example** (Lifting a Result function) * * ```ts @@ -6128,13 +7722,18 @@ export declare const flatMapNullishOr: { * @see {@link liftPredicate} — lift a boolean predicate * * @category lifting - * @since 2.0.0 + * @since 4.0.0 */ export declare const liftResult: , E, B>(f: (...a: A) => Result.Result) => (...a: A) => Array; /** - * Tests whether all elements satisfy the predicate. Supports refinements for + * Checks whether all elements satisfy the predicate. Supports refinements for * type narrowing. * + * **When to use** + * + * Use to check whether every array element satisfies a predicate, including + * refinement-based type narrowing. + * * **Example** (Testing all elements) * * ```ts @@ -6151,9 +7750,14 @@ export declare const liftResult: , E, B>(f: (...a: A) = */ export declare const every: { /** - * Tests whether all elements satisfy the predicate. Supports refinements for + * Checks whether all elements satisfy the predicate. Supports refinements for * type narrowing. * + * **When to use** + * + * Use to check whether every array element satisfies a predicate, including + * refinement-based type narrowing. + * * **Example** (Testing all elements) * * ```ts @@ -6170,9 +7774,14 @@ export declare const every: { */ (refinement: (a: NoInfer, i: number) => a is B): (self: ReadonlyArray) => self is ReadonlyArray; /** - * Tests whether all elements satisfy the predicate. Supports refinements for + * Checks whether all elements satisfy the predicate. Supports refinements for * type narrowing. * + * **When to use** + * + * Use to check whether every array element satisfies a predicate, including + * refinement-based type narrowing. + * * **Example** (Testing all elements) * * ```ts @@ -6189,9 +7798,14 @@ export declare const every: { */ (predicate: (a: NoInfer, i: number) => boolean): (self: ReadonlyArray) => boolean; /** - * Tests whether all elements satisfy the predicate. Supports refinements for + * Checks whether all elements satisfy the predicate. Supports refinements for * type narrowing. * + * **When to use** + * + * Use to check whether every array element satisfies a predicate, including + * refinement-based type narrowing. + * * **Example** (Testing all elements) * * ```ts @@ -6208,9 +7822,14 @@ export declare const every: { */ (self: ReadonlyArray, refinement: (a: A, i: number) => a is B): self is ReadonlyArray; /** - * Tests whether all elements satisfy the predicate. Supports refinements for + * Checks whether all elements satisfy the predicate. Supports refinements for * type narrowing. * + * **When to use** + * + * Use to check whether every array element satisfies a predicate, including + * refinement-based type narrowing. + * * **Example** (Testing all elements) * * ```ts @@ -6228,7 +7847,7 @@ export declare const every: { (self: ReadonlyArray, predicate: (a: A, i: number) => boolean): boolean; }; /** - * Tests whether at least one element satisfies the predicate. Narrows the type + * Checks whether at least one element satisfies the predicate. Narrows the type * to `NonEmptyReadonlyArray` on success. * * **Example** (Testing for any match) @@ -6248,7 +7867,7 @@ export declare const every: { */ export declare const some: { /** - * Tests whether at least one element satisfies the predicate. Narrows the type + * Checks whether at least one element satisfies the predicate. Narrows the type * to `NonEmptyReadonlyArray` on success. * * **Example** (Testing for any match) @@ -6268,7 +7887,7 @@ export declare const some: { */ (predicate: (a: NoInfer, i: number) => boolean): (self: ReadonlyArray) => self is NonEmptyReadonlyArray; /** - * Tests whether at least one element satisfies the predicate. Narrows the type + * Checks whether at least one element satisfies the predicate. Narrows the type * to `NonEmptyReadonlyArray` on success. * * **Example** (Testing for any match) @@ -6292,7 +7911,14 @@ export declare const some: { * Applies a function to each suffix of the array (starting from each index), * collecting the results. * - * - For index `i`, the function receives `self.slice(i)`. + * **When to use** + * + * Use when you need to compute a result from every suffix of an array, such as + * cumulative aggregations from each position. + * + * **Details** + * + * For index `i`, the function receives `self.slice(i)`. * * **Example** (Suffix lengths) * @@ -6302,6 +7928,8 @@ export declare const some: { * console.log(Array.extend([1, 2, 3], (as) => as.length)) // [3, 2, 1] * ``` * + * @see {@link scan} for keeping intermediate accumulator values during a fold + * * @category mapping * @since 2.0.0 */ @@ -6310,7 +7938,14 @@ export declare const extend: { * Applies a function to each suffix of the array (starting from each index), * collecting the results. * - * - For index `i`, the function receives `self.slice(i)`. + * **When to use** + * + * Use when you need to compute a result from every suffix of an array, such as + * cumulative aggregations from each position. + * + * **Details** + * + * For index `i`, the function receives `self.slice(i)`. * * **Example** (Suffix lengths) * @@ -6320,6 +7955,8 @@ export declare const extend: { * console.log(Array.extend([1, 2, 3], (as) => as.length)) // [3, 2, 1] * ``` * + * @see {@link scan} for keeping intermediate accumulator values during a fold + * * @category mapping * @since 2.0.0 */ @@ -6328,7 +7965,14 @@ export declare const extend: { * Applies a function to each suffix of the array (starting from each index), * collecting the results. * - * - For index `i`, the function receives `self.slice(i)`. + * **When to use** + * + * Use when you need to compute a result from every suffix of an array, such as + * cumulative aggregations from each position. + * + * **Details** + * + * For index `i`, the function receives `self.slice(i)`. * * **Example** (Suffix lengths) * @@ -6338,6 +7982,8 @@ export declare const extend: { * console.log(Array.extend([1, 2, 3], (as) => as.length)) // [3, 2, 1] * ``` * + * @see {@link scan} for keeping intermediate accumulator values during a fold + * * @category mapping * @since 2.0.0 */ @@ -6497,7 +8143,7 @@ export declare const unfold: (b: B, f: (b: B) => Option.Option(O: Order.Order) => Order.Order>; /** @@ -6517,12 +8163,17 @@ export declare const makeOrder: (O: Order.Order) => Order.Order(isEquivalent: Equivalence.Equivalence) => Equivalence.Equivalence>; /** * Runs a side-effect for each element. The callback receives `(element, index)`. * + * **When to use** + * + * Use to iterate over an array for side-effects only, when no transformed + * result is needed. + * * **Example** (Iterating with side-effects) * * ```ts @@ -6531,6 +8182,8 @@ export declare const makeEquivalence: (isEquivalent: Equivalence.Equivalence< * Array.forEach([1, 2, 3], (n) => console.log(n)) // 1, 2, 3 * ``` * + * @see {@link map} for transforming each element into a new array + * * @category elements * @since 2.0.0 */ @@ -6538,6 +8191,11 @@ export declare const forEach: { /** * Runs a side-effect for each element. The callback receives `(element, index)`. * + * **When to use** + * + * Use to iterate over an array for side-effects only, when no transformed + * result is needed. + * * **Example** (Iterating with side-effects) * * ```ts @@ -6546,6 +8204,8 @@ export declare const forEach: { * Array.forEach([1, 2, 3], (n) => console.log(n)) // 1, 2, 3 * ``` * + * @see {@link map} for transforming each element into a new array + * * @category elements * @since 2.0.0 */ @@ -6553,6 +8213,11 @@ export declare const forEach: { /** * Runs a side-effect for each element. The callback receives `(element, index)`. * + * **When to use** + * + * Use to iterate over an array for side-effects only, when no transformed + * result is needed. + * * **Example** (Iterating with side-effects) * * ```ts @@ -6561,6 +8226,8 @@ export declare const forEach: { * Array.forEach([1, 2, 3], (n) => console.log(n)) // 1, 2, 3 * ``` * + * @see {@link map} for transforming each element into a new array + * * @category elements * @since 2.0.0 */ @@ -6570,6 +8237,11 @@ export declare const forEach: { * Removes duplicates using a custom equivalence, preserving the order of the * first occurrence. * + * **When to use** + * + * Use to remove all duplicate elements with a custom equivalence when default + * equality is not appropriate. + * * **Example** (Deduplicating with custom equality) * * ```ts @@ -6589,6 +8261,11 @@ export declare const dedupeWith: { * Removes duplicates using a custom equivalence, preserving the order of the * first occurrence. * + * **When to use** + * + * Use to remove all duplicate elements with a custom equivalence when default + * equality is not appropriate. + * * **Example** (Deduplicating with custom equality) * * ```ts @@ -6608,6 +8285,11 @@ export declare const dedupeWith: { * Removes duplicates using a custom equivalence, preserving the order of the * first occurrence. * + * **When to use** + * + * Use to remove all duplicate elements with a custom equivalence when default + * equality is not appropriate. + * * **Example** (Deduplicating with custom equality) * * ```ts @@ -6627,6 +8309,11 @@ export declare const dedupeWith: { * Removes duplicates using a custom equivalence, preserving the order of the * first occurrence. * + * **When to use** + * + * Use to remove all duplicate elements with a custom equivalence when default + * equality is not appropriate. + * * **Example** (Deduplicating with custom equality) * * ```ts @@ -6647,6 +8334,11 @@ export declare const dedupeWith: { * Removes duplicates using `Equal.equivalence()`, preserving the order of the * first occurrence. * + * **When to use** + * + * Use to remove repeated values from an iterable when Effect's default equality + * is the right comparison, preserving the first occurrence. + * * **Example** (Removing duplicates) * * ```ts @@ -6665,7 +8357,15 @@ export declare const dedupe: >(self: S) => S extends Non /** * Removes consecutive duplicate elements using a custom equivalence. * - * - Non-adjacent duplicates are preserved. + * **When to use** + * + * Use when consecutive duplicates should be collapsed using a custom + * equivalence, while equivalent values that appear later should remain in the + * result. + * + * **Details** + * + * Non-adjacent duplicates are preserved. * * **Example** (Deduplicating adjacent elements) * @@ -6686,7 +8386,15 @@ export declare const dedupeAdjacentWith: { /** * Removes consecutive duplicate elements using a custom equivalence. * - * - Non-adjacent duplicates are preserved. + * **When to use** + * + * Use when consecutive duplicates should be collapsed using a custom + * equivalence, while equivalent values that appear later should remain in the + * result. + * + * **Details** + * + * Non-adjacent duplicates are preserved. * * **Example** (Deduplicating adjacent elements) * @@ -6707,7 +8415,15 @@ export declare const dedupeAdjacentWith: { /** * Removes consecutive duplicate elements using a custom equivalence. * - * - Non-adjacent duplicates are preserved. + * **When to use** + * + * Use when consecutive duplicates should be collapsed using a custom + * equivalence, while equivalent values that appear later should remain in the + * result. + * + * **Details** + * + * Non-adjacent duplicates are preserved. * * **Example** (Deduplicating adjacent elements) * @@ -6729,6 +8445,11 @@ export declare const dedupeAdjacentWith: { /** * Removes consecutive duplicate elements using `Equal.equivalence()`. * + * **When to use** + * + * Use when you need to collapse consecutive duplicates while preserving later + * non-consecutive repeats, and the default equality is sufficient. + * * **Example** (Removing adjacent duplicates) * * ```ts @@ -6757,8 +8478,8 @@ export declare const dedupeAdjacent: (self: Iterable) => Array; * * @see {@link intersperse} — insert separator elements without joining * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ export declare const join: { /** @@ -6774,8 +8495,8 @@ export declare const join: { * * @see {@link intersperse} — insert separator elements without joining * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ (sep: string): (self: Iterable) => string; /** @@ -6791,18 +8512,25 @@ export declare const join: { * * @see {@link intersperse} — insert separator elements without joining * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ (self: Iterable, sep: string): string; }; /** * Maps over an array while threading an accumulator through each step, returning both the final state and the mapped array. * - * - Combines `map` and `reduce` in a single pass. - * - The callback receives the current state, element, and index, and returns `[nextState, mappedValue]`. - * - Returns `[finalState, mappedArray]`. - * - Dual: can be used in both data-first and data-last style. + * **When to use** + * + * Use when you need to map while threading state through each element and keep + * the final state. + * + * **Details** + * + * Combines `map` and `reduce` in a single pass. The callback receives the + * current state, element, and index, and returns `[nextState, mappedValue]`. + * The result is `[finalState, mappedArray]`. This can be used in both + * data-first and data-last style. * * **Example** (Running sum alongside mapped values) * @@ -6816,17 +8544,24 @@ export declare const join: { * @see {@link scan} — when you only need the accumulated results (not the final state) * @see {@link reduce} — when you only need the final accumulated value * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ export declare const mapAccum: { /** * Maps over an array while threading an accumulator through each step, returning both the final state and the mapped array. * - * - Combines `map` and `reduce` in a single pass. - * - The callback receives the current state, element, and index, and returns `[nextState, mappedValue]`. - * - Returns `[finalState, mappedArray]`. - * - Dual: can be used in both data-first and data-last style. + * **When to use** + * + * Use when you need to map while threading state through each element and keep + * the final state. + * + * **Details** + * + * Combines `map` and `reduce` in a single pass. The callback receives the + * current state, element, and index, and returns `[nextState, mappedValue]`. + * The result is `[finalState, mappedArray]`. This can be used in both + * data-first and data-last style. * * **Example** (Running sum alongside mapped values) * @@ -6840,17 +8575,24 @@ export declare const mapAccum: { * @see {@link scan} — when you only need the accumulated results (not the final state) * @see {@link reduce} — when you only need the final accumulated value * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ = Iterable>(s: S, f: (s: S, a: ReadonlyArray.Infer, i: number) => readonly [S, B]): (self: I) => [state: S, mappedArray: ReadonlyArray.With]; /** * Maps over an array while threading an accumulator through each step, returning both the final state and the mapped array. * - * - Combines `map` and `reduce` in a single pass. - * - The callback receives the current state, element, and index, and returns `[nextState, mappedValue]`. - * - Returns `[finalState, mappedArray]`. - * - Dual: can be used in both data-first and data-last style. + * **When to use** + * + * Use when you need to map while threading state through each element and keep + * the final state. + * + * **Details** + * + * Combines `map` and `reduce` in a single pass. The callback receives the + * current state, element, and index, and returns `[nextState, mappedValue]`. + * The result is `[finalState, mappedArray]`. This can be used in both + * data-first and data-last style. * * **Example** (Running sum alongside mapped values) * @@ -6864,17 +8606,24 @@ export declare const mapAccum: { * @see {@link scan} — when you only need the accumulated results (not the final state) * @see {@link reduce} — when you only need the final accumulated value * - * @since 2.0.0 * @category folding + * @since 2.0.0 */ = Iterable>(self: I, s: S, f: (s: S, a: ReadonlyArray.Infer, i: number) => readonly [S, B]): [state: S, mappedArray: ReadonlyArray.With]; }; /** * Computes the cartesian product of two arrays, applying a combiner to each pair. * - * - Produces every combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. - * - Order: iterates `that` for each element of `self`. + * **When to use** + * + * Use to compute every combination from two arrays and immediately transform + * each pair into a custom result. + * + * **Details** + * + * Produces every combination of an element from `self` with an element from + * `that`, so the result length is `self.length * that.length`. Iteration visits + * every element of `that` for each element of `self`. * * **Example** (Combining numbers and letters) * @@ -6885,18 +8634,25 @@ export declare const mapAccum: { * console.log(result) // ["1-a", "1-b", "2-a", "2-b"] * ``` * - * @see {@link cartesian} — returns tuples instead of applying a combiner + * @see {@link cartesian} for returning tuples instead of applying a combiner * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const cartesianWith: { /** * Computes the cartesian product of two arrays, applying a combiner to each pair. * - * - Produces every combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. - * - Order: iterates `that` for each element of `self`. + * **When to use** + * + * Use to compute every combination from two arrays and immediately transform + * each pair into a custom result. + * + * **Details** + * + * Produces every combination of an element from `self` with an element from + * `that`, so the result length is `self.length * that.length`. Iteration visits + * every element of `that` for each element of `self`. * * **Example** (Combining numbers and letters) * @@ -6907,18 +8663,25 @@ export declare const cartesianWith: { * console.log(result) // ["1-a", "1-b", "2-a", "2-b"] * ``` * - * @see {@link cartesian} — returns tuples instead of applying a combiner + * @see {@link cartesian} for returning tuples instead of applying a combiner * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (that: ReadonlyArray, f: (a: A, b: B) => C): (self: ReadonlyArray) => Array; /** * Computes the cartesian product of two arrays, applying a combiner to each pair. * - * - Produces every combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. - * - Order: iterates `that` for each element of `self`. + * **When to use** + * + * Use to compute every combination from two arrays and immediately transform + * each pair into a custom result. + * + * **Details** + * + * Produces every combination of an element from `self` with an element from + * `that`, so the result length is `self.length * that.length`. Iteration visits + * every element of `that` for each element of `self`. * * **Example** (Combining numbers and letters) * @@ -6929,18 +8692,24 @@ export declare const cartesianWith: { * console.log(result) // ["1-a", "1-b", "2-a", "2-b"] * ``` * - * @see {@link cartesian} — returns tuples instead of applying a combiner + * @see {@link cartesian} for returning tuples instead of applying a combiner * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: ReadonlyArray, that: ReadonlyArray, f: (a: A, b: B) => C): Array; }; /** * Computes the cartesian product of two arrays, returning all pairs as tuples. * - * - Produces every `[a, b]` combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. + * **When to use** + * + * Use when you need every `[a, b]` pair from two arrays as tuples. + * + * **Details** + * + * Produces every `[a, b]` combination of an element from `self` with an element + * from `that`, so the result length is `self.length * that.length`. * * **Example** (All pairs of two arrays) * @@ -6953,15 +8722,21 @@ export declare const cartesianWith: { * * @see {@link cartesianWith} — apply a combiner to each pair * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ export declare const cartesian: { /** * Computes the cartesian product of two arrays, returning all pairs as tuples. * - * - Produces every `[a, b]` combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. + * **When to use** + * + * Use when you need every `[a, b]` pair from two arrays as tuples. + * + * **Details** + * + * Produces every `[a, b]` combination of an element from `self` with an element + * from `that`, so the result length is `self.length * that.length`. * * **Example** (All pairs of two arrays) * @@ -6974,15 +8749,21 @@ export declare const cartesian: { * * @see {@link cartesianWith} — apply a combiner to each pair * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (that: ReadonlyArray): (self: ReadonlyArray) => Array<[A, B]>; /** * Computes the cartesian product of two arrays, returning all pairs as tuples. * - * - Produces every `[a, b]` combination of an element from `self` with an element from `that`. - * - Result length is `self.length * that.length`. + * **When to use** + * + * Use when you need every `[a, b]` pair from two arrays as tuples. + * + * **Details** + * + * Produces every `[a, b]` combination of an element from `self` with an element + * from `that`, so the result length is `self.length * that.length`. * * **Example** (All pairs of two arrays) * @@ -6995,17 +8776,24 @@ export declare const cartesian: { * * @see {@link cartesianWith} — apply a combiner to each pair * - * @since 2.0.0 * @category elements + * @since 2.0.0 */ (self: ReadonlyArray, that: ReadonlyArray): Array<[A, B]>; }; /** - * Starting point for the "do simulation" — an array comprehension pattern. + * Provides the starting point for the "do simulation" — an array comprehension pattern. + * + * **When to use** + * + * Use when you want array-comprehension style code with do notation. + * + * **Details** * - * - Begin a pipeline with `Do`, then use {@link bind} to introduce array variables and {@link let_ let} for plain values. - * - Each `bind` produces the cartesian product of all bound variables (like nested loops). - * - Use `filter` and `map` in the pipeline to add conditions and transformations. + * Use {@link bind} to introduce array variables and {@link let_ let} for plain + * values. Each `bind` produces the cartesian product of all bound variables, + * like nested loops. Use `filter` and `map` in the pipeline to add conditions + * and transformations. * * **Example** (Array comprehension with do notation) * @@ -7031,11 +8819,18 @@ export declare const cartesian: { */ export declare const Do: ReadonlyArray<{}>; /** - * Introduces a new array variable into a do-notation scope, producing the cartesian product with all previous bindings. + * Adds a new array variable to a do-notation scope, producing the cartesian product with all previous bindings. * - * - Each `bind` call adds a named property to the accumulated object. - * - The callback receives the current scope and must return an array. - * - Equivalent to `flatMap` + merging the new value into the scope object. + * **When to use** + * + * Use to add another array-producing binding to an `Array.Do` pipeline, pairing + * each existing scope with every value returned by the callback. + * + * **Details** + * + * Each `bind` call adds a named property to the accumulated object. The + * callback receives the current scope and must return an array. This is + * equivalent to `flatMap` plus merging the new value into the scope object. * * **Example** (Binding two arrays) * @@ -7060,11 +8855,18 @@ export declare const Do: ReadonlyArray<{}>; */ export declare const bind: { /** - * Introduces a new array variable into a do-notation scope, producing the cartesian product with all previous bindings. + * Adds a new array variable to a do-notation scope, producing the cartesian product with all previous bindings. + * + * **When to use** * - * - Each `bind` call adds a named property to the accumulated object. - * - The callback receives the current scope and must return an array. - * - Equivalent to `flatMap` + merging the new value into the scope object. + * Use to add another array-producing binding to an `Array.Do` pipeline, pairing + * each existing scope with every value returned by the callback. + * + * **Details** + * + * Each `bind` call adds a named property to the accumulated object. The + * callback receives the current scope and must return an array. This is + * equivalent to `flatMap` plus merging the new value into the scope object. * * **Example** (Binding two arrays) * @@ -7091,11 +8893,18 @@ export declare const bind: { [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; /** - * Introduces a new array variable into a do-notation scope, producing the cartesian product with all previous bindings. + * Adds a new array variable to a do-notation scope, producing the cartesian product with all previous bindings. + * + * **When to use** + * + * Use to add another array-producing binding to an `Array.Do` pipeline, pairing + * each existing scope with every value returned by the callback. * - * - Each `bind` call adds a named property to the accumulated object. - * - The callback receives the current scope and must return an array. - * - Equivalent to `flatMap` + merging the new value into the scope object. + * **Details** + * + * Each `bind` call adds a named property to the accumulated object. The + * callback receives the current scope and must return an array. This is + * equivalent to `flatMap` plus merging the new value into the scope object. * * **Example** (Binding two arrays) * @@ -7123,10 +8932,17 @@ export declare const bind: { }>; }; /** - * Names the elements of an array by wrapping each in an object with the given key, starting a do-notation scope. + * Wraps each array element in an object with the given key, starting a do-notation scope. + * + * **When to use** + * + * Use when you already have an array and want to start a do-notation pipeline + * by naming each element. + * + * **Details** * - * - Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. - * - Alternative to starting with `Do` + `bind`; useful when you already have an array. + * Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. This is an + * alternative to starting with `Do` plus `bind` when you already have an array. * * **Example** (Naming an existing array) * @@ -7148,10 +8964,17 @@ export declare const bind: { */ export declare const bindTo: { /** - * Names the elements of an array by wrapping each in an object with the given key, starting a do-notation scope. + * Wraps each array element in an object with the given key, starting a do-notation scope. * - * - Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. - * - Alternative to starting with `Do` + `bind`; useful when you already have an array. + * **When to use** + * + * Use when you already have an array and want to start a do-notation pipeline + * by naming each element. + * + * **Details** + * + * Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. This is an + * alternative to starting with `Do` plus `bind` when you already have an array. * * **Example** (Naming an existing array) * @@ -7175,10 +8998,17 @@ export declare const bindTo: { [K in N]: A; }>; /** - * Names the elements of an array by wrapping each in an object with the given key, starting a do-notation scope. + * Wraps each array element in an object with the given key, starting a do-notation scope. + * + * **When to use** * - * - Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. - * - Alternative to starting with `Do` + `bind`; useful when you already have an array. + * Use when you already have an array and want to start a do-notation pipeline + * by naming each element. + * + * **Details** + * + * Equivalent to `Array.map(self, (a) => ({ [tag]: a }))`. This is an + * alternative to starting with `Do` plus `bind` when you already have an array. * * **Example** (Naming an existing array) * @@ -7214,8 +9044,16 @@ export { /** * Adds a computed plain value to the do-notation scope without introducing a new array dimension. * - * - Unlike {@link bind}, the callback returns a single value (not an array), so no cartesian product occurs. - * - Useful for derived or intermediate values that depend on previously bound variables. + * **When to use** + * + * Use when each do-notation branch needs a derived field from the current + * bindings without multiplying the number of branches. + * + * **Details** + * + * Unlike `bind`, the callback returns a single value instead of an array, so + * no cartesian product occurs. Use this for derived or intermediate values + * that depend on previously bound variables. * * **Example** (Adding a computed value) * @@ -7243,6 +9081,7 @@ let_ as let }; * * @see {@link makeReducerConcat} — mutable `Array` variant * + * @category folding * @since 4.0.0 */ export declare function getReadonlyReducerConcat(): Reducer.Reducer>; @@ -7251,14 +9090,22 @@ export declare function getReadonlyReducerConcat(): Reducer.Reducer(): Reducer.Reducer>; /** - * Counts the elements in an iterable that satisfy a predicate. + * Computes the number of elements in an iterable that satisfy a predicate. + * + * **When to use** * - * - The predicate receives both the element and its index. - * - Returns `0` for an empty iterable. + * Use when you need to count how many elements of an iterable satisfy a + * predicate. + * + * **Details** + * + * The predicate receives both the element and its index. Empty iterables return + * `0`. * * **Example** (Counting even numbers) * @@ -7276,10 +9123,17 @@ export declare function makeReducerConcat(): Reducer.Reducer>; */ export declare const countBy: { /** - * Counts the elements in an iterable that satisfy a predicate. + * Computes the number of elements in an iterable that satisfy a predicate. + * + * **When to use** + * + * Use when you need to count how many elements of an iterable satisfy a + * predicate. * - * - The predicate receives both the element and its index. - * - Returns `0` for an empty iterable. + * **Details** + * + * The predicate receives both the element and its index. Empty iterables return + * `0`. * * **Example** (Counting even numbers) * @@ -7297,10 +9151,17 @@ export declare const countBy: { */ (predicate: (a: NoInfer, i: number) => boolean): (self: Iterable) => number; /** - * Counts the elements in an iterable that satisfy a predicate. + * Computes the number of elements in an iterable that satisfy a predicate. + * + * **When to use** + * + * Use when you need to count how many elements of an iterable satisfy a + * predicate. + * + * **Details** * - * - The predicate receives both the element and its index. - * - Returns `0` for an empty iterable. + * The predicate receives both the element and its index. Empty iterables return + * `0`. * * **Example** (Counting even numbers) *