import { Resolvable } from "jtilz"; //#region src/types.d.ts /** * Identity function. Return type is the same as the argument type (but values may differ). */ type ID = (a: T) => T; type nil = null | undefined; //#endregion //#region src/imp/array.d.ts /** * Appends elements onto the end of the array. */ declare function arrayPush(array: T[] | nil, ...values: T[]): T[]; /** * Pops an element off the end of the array. */ declare function arrayPop(array: T[] | nil, howMany?: number): T[]; /** * Insert one or more elements into an array at the given position. */ declare function arrayInsert(array: T[] | nil, index: number, ...values: T[]): T[]; /** * Insert numbers into a sorted array, using binary search to find their position. * * @param array Array of numbers. Must be sorted in ascending order. * @param values Values to insert. These needn't be sorted; each one will be searched for individually. */ declare function arrayInsertSorted(array: number[] | nil, ...values: number[]): number[]; /** * Prepends elements onto the end of the array. */ declare function arrayUnshift(array: T[] | nil, ...values: T[]): T[]; /** * Deletes elements from an array by index. */ declare function arrayDeleteIndex(array: T[] | nil, ...indices: number[]): T[]; /** * Deletes up to one element from an array, searching by value. * @deprecated */ declare function arrayDeleteOneValue(array: T[] | nil, value: T, strict: boolean): T[]; /** * Deletes up to one element from an array, searching by value. */ declare function arrayDeleteValue(array: T[] | nil, value: T, strict: boolean, limit?: number): T[]; /** * Filters the array to elements that pass the predicate. * If limit is provided, returned array will be at most that length. */ declare function arraySelect(array: T[] | nil, predicate: (v: T, i: number) => boolean, limit?: number): T[]; /** * Removes elements that do *not* pass the predicate. * If limit is provided, at most that many elements will be deleted. i.e. new length will be >= array.length - limit. */ declare function arrayReject(array: T[] | nil, predicate: (v: T, i: number) => boolean, limit?: number): T[]; declare function arraySort(array: T[] | nil, compareFn: (a: T, b: T) => number): T[]; declare function arraySortNumbers(array: number[] | nil, ascending?: boolean): number[]; interface CollatorOptions extends Intl.CollatorOptions { /** * A string with a BCP 47 language tag, or an array of such strings. */ locales?: string | string[]; /** * Sort in ascending order (alphabetically, A->Z). */ ascending?: boolean; } declare function arraySortStrings(array: string[] | nil, options?: CollatorOptions): string[]; /** * Replaces `count` elements starting at the given `index` with `replaceWith` elements. * * @param array Array to remove value from * @param index Index to remove * @param count * @param replaceWith * @returns Array with `value` removed */ declare function arraySplice(array: T[] | nil, index: number, count?: number, ...replaceWith: T[]): T[]; type ArrayPredicate = (v: T, i: number) => boolean; type ArrayElementResolvable = Resolvable; declare function arrayFindAndReplace(array: T[], predicate: ArrayPredicate, replaceWith: ArrayElementResolvable): T[]; /** * Swap 2 elements of an array. * * @param array Array to update * @param indexA Index of first element * @param indexB Index of second element */ declare function arraySwap(array: T[], indexA: number, indexB: number): T[]; /** * Replace an element at the given index. * Same as {@link arraySplice} but with `count=1` * * @param array * @param index * @param replaceWith */ declare function arrayReplace(array: T[], index: number, ...replaceWith: T[]): T[]; //#endregion export { arraySplice as _, arrayDeleteValue as a, ID as b, arrayInsertSorted as c, arrayReject as d, arrayReplace as f, arraySortStrings as g, arraySortNumbers as h, arrayDeleteOneValue as i, arrayPop as l, arraySort as m, ArrayPredicate as n, arrayFindAndReplace as o, arraySelect as p, arrayDeleteIndex as r, arrayInsert as s, ArrayElementResolvable as t, arrayPush as u, arraySwap as v, nil as x, arrayUnshift as y };