import type { AnyCaller } from "./function.js"; /** * Mutable array: an array that can be changed. * - Consistency with `MutableObject` and `ImmutableArray` */ export type MutableArray = T[]; /** * Immutable array: an array that cannot be changed. * - Consistency with `ImmutableObject` and `MutableArray` */ export type ImmutableArray = readonly T[]; /** Get the type of the _items_ in an array. */ export type ArrayItem = T[number]; /** Things that can be converted to arrays. */ export type PossibleArray = ImmutableArray | Iterable; /** Is an unknown value an array (optionally with specified min/max length). */ export declare function isArray(arr: MutableArray, min: 1, max: 1): arr is [T]; export declare function isArray(arr: MutableArray, min: 2, max: 2): arr is [T, T]; export declare function isArray(arr: MutableArray, min: 3, max: 3): arr is [T, T, T]; export declare function isArray(arr: MutableArray, min?: 1, max?: number): arr is [T, ...T[]]; export declare function isArray(arr: MutableArray, min: 2, max?: number): arr is [T, T, ...T[]]; export declare function isArray(arr: MutableArray, min: 3, max?: number): arr is [T, T, T, ...T[]]; export declare function isArray(arr: MutableArray, min?: number, max?: number): arr is MutableArray; export declare function isArray(arr: ImmutableArray, min: 1, max: 1): arr is readonly [T]; export declare function isArray(arr: ImmutableArray, min: 2, max: 2): arr is readonly [T, T]; export declare function isArray(arr: ImmutableArray, min: 3, max: 3): arr is readonly [T, T, T]; export declare function isArray(arr: ImmutableArray, min?: 1, max?: number): arr is readonly [T, ...T[]]; export declare function isArray(arr: ImmutableArray, min: 2, max?: number): arr is readonly [T, T, ...T[]]; export declare function isArray(arr: ImmutableArray, min: 3, max?: number): arr is readonly [T, T, T, ...T[]]; export declare function isArray(value: unknown, min?: number, max?: number): value is ImmutableArray; /** Assert that an unknown value is an array (optionally with specified min/max length). */ export declare function assertArray(arr: MutableArray, min: 1, max: 1, caller?: AnyCaller): asserts arr is [T]; export declare function assertArray(arr: MutableArray, min: 2, max: 2, caller?: AnyCaller): asserts arr is [T, T]; export declare function assertArray(arr: MutableArray, min: 3, max: 3, caller?: AnyCaller): asserts arr is [T, T, T]; export declare function assertArray(arr: MutableArray, min?: 1, max?: number, caller?: AnyCaller): asserts arr is [T, ...T[]]; export declare function assertArray(arr: MutableArray, min: 2, max?: number, caller?: AnyCaller): asserts arr is [T, T, ...T[]]; export declare function assertArray(arr: MutableArray, min: 3, max?: number, caller?: AnyCaller): asserts arr is [T, T, T, ...T[]]; export declare function assertArray(arr: MutableArray, min: number, max?: number, caller?: AnyCaller): asserts arr is MutableArray; export declare function assertArray(arr: ImmutableArray, min: 1, max: 1, caller?: AnyCaller): asserts arr is readonly [T]; export declare function assertArray(arr: ImmutableArray, min: 2, max: 2, caller?: AnyCaller): asserts arr is readonly [T, T]; export declare function assertArray(arr: ImmutableArray, min: 3, max: 3, caller?: AnyCaller): asserts arr is readonly [T, T, T]; export declare function assertArray(arr: ImmutableArray, min?: 1, max?: number, caller?: AnyCaller): asserts arr is readonly [T, ...T[]]; export declare function assertArray(arr: ImmutableArray, min: 2, max?: number, caller?: AnyCaller): asserts arr is readonly [T, T, ...T[]]; export declare function assertArray(arr: ImmutableArray, min: 3, max?: number, caller?: AnyCaller): asserts arr is readonly [T, T, T, ...T[]]; export declare function assertArray(arr: ImmutableArray, min?: number, max?: number, caller?: AnyCaller): asserts arr is ImmutableArray; /** Convert a possible array to an array. */ export declare function getArray(list: unknown): ImmutableArray | undefined; /** Convert a possible array to an array (optionally with specified min/max length), or throw `RequiredError` if conversion fails. */ export declare function requireArray(arr: MutableArray, min: 1, max: 1, caller?: AnyCaller): [T]; export declare function requireArray(arr: MutableArray, min: 2, max: 2, caller?: AnyCaller): [T, T]; export declare function requireArray(arr: MutableArray, min: 3, max: 3, caller?: AnyCaller): [T, T, T]; export declare function requireArray(arr: MutableArray, min?: 1, max?: number, caller?: AnyCaller): [T, ...T[]]; export declare function requireArray(arr: MutableArray, min: 2, max?: number, caller?: AnyCaller): [T, T, ...T[]]; export declare function requireArray(arr: MutableArray, min: 3, max?: number, caller?: AnyCaller): [T, T, T, ...T[]]; export declare function requireArray(arr: MutableArray, min?: number, max?: number, caller?: AnyCaller): MutableArray; export declare function requireArray(arr: ImmutableArray, min: 1, max: 1, caller?: AnyCaller): readonly [T]; export declare function requireArray(arr: ImmutableArray, min: 2, max: 2, caller?: AnyCaller): readonly [T, T]; export declare function requireArray(arr: ImmutableArray, min: 3, max: 3, caller?: AnyCaller): readonly [T, T, T]; export declare function requireArray(arr: ImmutableArray, min?: 1, max?: number, caller?: AnyCaller): readonly [T, ...T[]]; export declare function requireArray(arr: ImmutableArray, min: 2, max?: number, caller?: AnyCaller): readonly [T, T, ...T[]]; export declare function requireArray(arr: ImmutableArray, min: 3, max?: number, caller?: AnyCaller): readonly [T, T, T, ...T[]]; export declare function requireArray(list: PossibleArray, min?: number, max?: number, caller?: AnyCaller): ImmutableArray; /** Is an unknown value an item in a specified array or iterable? */ export declare function isArrayItem(list: PossibleArray, item: unknown): item is T; /** Assert that an unknown value is an item in a specified array. */ export declare function assertArrayItem(arr: PossibleArray, item: unknown, caller?: AnyCaller): asserts item is T; /** Add multiple items to an array (immutably) and return a new array with those items (or the same array if no changes were made). */ export declare function withArrayItems(list: PossibleArray, ...add: T[]): ImmutableArray; /** Add an item to an array (immutably) and return a new array with that item (or the same array if no changes were made). */ export declare const withArrayItem: (items: PossibleArray, add: T) => ImmutableArray; /** Pick multiple items from an array (immutably) and return a new array with those items (or the same array if no changes were made). */ export declare function pickArrayItems(items: PossibleArray, ...pick: T[]): ImmutableArray; /** Pick an item from an array (immutably) and return a new array with that item (or the same array if no changes were made). */ export declare const pickArrayItem: (items: PossibleArray, pick: T) => ImmutableArray; /** Remove multiple items from an array (immutably) and return a new array without those items (or the same array if no changes were made). */ export declare function omitArrayItems(items: PossibleArray, ...omit: T[]): ImmutableArray; /** Remove an item from an array (immutably) and return a new array without those items (or the same array if no changes were made). */ export declare const omitArrayItem: (items: PossibleArray, omit: T) => ImmutableArray; /** Toggle an item in and out of an array (immutably) and return a new array with or without the specified items (or the same array if no changes were made). */ export declare function toggleArrayItems(items: PossibleArray, ...toggle: T[]): ImmutableArray; /** Toggle an item in and out of an array (immutably) and return a new array with or without the specified item (or the same array if no changes were made). */ export declare const toggleArrayItem: (items: PossibleArray, toggle: T) => ImmutableArray; /** Return a shuffled version of an array or iterable. */ export declare function shuffleArray(items: PossibleArray): ImmutableArray; /** * Add an item to an array (by reference) and return the item. * - Skip items that already exist. */ export declare function addArrayItem(arr: MutableArray, item: T): T; /** * Add multiple items to an array (by reference). * - Skip items that already exist. */ export declare function addArrayItems(arr: MutableArray, ...items: T[]): void; /** Remove multiple items from an array (by reference). */ export declare function deleteArrayItems(arr: MutableArray, ...items: T[]): void; /** Remove an item from an array (by reference). */ export declare const deleteArrayItem: (arr: MutableArray, item: T) => void; /** Return an array of the unique items in an array. */ export declare function getUniqueArray(list: PossibleArray): ImmutableArray; /** Apply a limit to an array. */ export declare function limitArray(list: PossibleArray, limit: number): ImmutableArray; /** Count the items in an array. */ export declare function countArray(arr: ImmutableArray): number; /** Interleave array items with a separator */ export declare function interleaveArray(items: PossibleArray, separator: T): ImmutableArray; export declare function interleaveArray(items: PossibleArray, separator: B): ImmutableArray; /** Get the first item from an array or iterable, or `undefined` if it didn't exist. */ export declare function getFirst(items: PossibleArray): T | undefined; /** Get the first item from an array or iterable. */ export declare function requireFirst(items: PossibleArray, caller?: AnyCaller): T; /** Get the last item from an array or iterable, or `undefined` if it didn't exist. */ export declare function getLast(items: PossibleArray): T | undefined; /** Get the last item from an array or iterable. */ export declare function requireLast(items: PossibleArray, caller?: AnyCaller): T; /** Get the next item in an array or iterable. */ export declare function getNext(items: PossibleArray, item: T): T | undefined; /** Get the next item from an array or iterable. */ export declare function requireNext(items: PossibleArray, item: T, caller?: AnyCaller): T; /** Get the previous item in an array or iterable. */ export declare function getPrev(items: PossibleArray, value: T): T | undefined; /** Get the previous item from an array or iterable. */ export declare function requirePrev(items: PossibleArray, item: T, caller?: AnyCaller): T;