/**
* ============================================================================
* IMPORTS
* ============================================================================
* @hidden
*/
import type { Optional } from "./Type";
/**
* ============================================================================
* UTILITY FUNCTIONS
* ============================================================================
* @hidden
*/
/**
* Searches `array` for `value`.
*
* Returns -1 if not found.
*
* @param array Source array
* @param value Value to search
* @returns Index
*/
export declare function indexOf(array: ArrayLike, value: A): number;
/**
* Returns `true` if `test` returns `true` for any item of `array`, stopping
* at the first one.
*
* @param array Source array
* @param test Function which is called on each element
* @returns Whether `test` returned true or not
*/
export declare function any(array: ArrayLike, test: (value: A) => boolean): boolean;
/**
* Calls `fn` function for every member of array and returns a new array out
* of all outputs.
*
* @param array Source array
* @param fn Callback function
* @returns New array
*/
export declare function map(array: ArrayLike, fn: (value: A, index: number) => B): Array;
/**
* Iterates through all items in array and calls `fn` function for each of
* them.
*
* @param array Source array
* @param fn Callback function
*/
export declare function each(array: ArrayLike, fn: (value: A, index: number) => void): void;
/**
* Iterates through all items in array in reverse order and calls `fn` function for each of
* them.
*
* @param array Source array
* @param fn Callback function
*/
export declare function eachReverse(array: ArrayLike, fn: (value: A, index: number) => void): void;
/**
* Iterates through all items in array and calls `fn` function for each of
* them.
*
* If `fn` call evaluates to `false`, further iteration is cancelled.
*
* @param array Source array
* @param fn Callback function
*/
export declare function eachContinue(array: ArrayLike, fn: (value: A, index: number) => boolean): void;
/**
* Removes the first `index` items of `array` in place, moving the rest to the
* beginning.
*
* @param array Source array
* @param index Number of items to remove
*/
export declare function shiftLeft(array: Array, index: number): void;
/**
* Returns the last item of the array.
*
* @param array Source array
* @returns Last item
*/
export declare function last(array: Array): Optional;
/**
* Returns the first item of the array.
*
* @param array Source array
* @returns First item
*/
export declare function first(array: Array): Optional;
/**
* Inserts `element` into `array` at `index`, clamped to `0` to
* `array.length`.
*
* @param array Source array
* @param element Item to insert
* @param index Index to insert item at
*/
export declare function insert(array: Array, element: A, index: number): void;
/**
* Removes all copies of `element` from `array` (if they exist) and then
* inserts `element` at `index`.
*
* @param array Source array
* @param element Item
* @param index Index to move item to
*/
export declare function setIndex(array: Array, element: A, index: number): void;
/**
* Pushes all of the elements from `input` into `array`.
*
* @param array Output array
* @param input Input array
*/
export declare function pushAll(array: Array, input: Array): void;
/**
* Removes `element` from `array`.
*
* If there are multiple copies of `element`, they are all removed.
*
* @param array Source array
* @param element Item to remove
* @returns Whether `element` was found
*/
export declare function remove(array: Array, element: A): boolean;
/**
* Removes the first copy of `element` from `array`.
*
* @param array Source array
* @param element Item to remove
* @returns Whether `element` was found
*/
export declare function removeFirst(array: Array, element: A): boolean;
/**
* Adds `element` to `array` at `toIndex`, or at the end if `toIndex` is not
* set. If `array` already contains `element`, its first copy is removed
* first.
*
* @param array Source array
* @param element Item to add
* @param toIndex Index to move item to
*/
export declare function move(array: Array, element: A, toIndex?: number): void;
/**
* Inserts `element` into `array` at `index`.
*
* If `index` is not provided, it will insert `element` at the end of `array`.
*
* @param array Source array
* @param element Item to add
* @param index Index to add item at
*/
export declare function add(array: Array, element: A, index?: number): void;
/**
* Pushes `element` into `array` if it doesn't already exist.
*
* @param array Source array
* @param element Item to add
*/
export declare function pushOne(array: Array, element: A): void;
/**
* Removes the first copy of `element` from `array` (if it exists) and then
* inserts `element` at `index`.
*
* If `index` is not provided, it will insert `element` at the end of `array`.
*
* @param array Source array
* @param element Item to move
* @param index Index to move item to
*/
export declare function replace(array: Array, element: A, index?: number): void;
/**
* Wraps `input` in an array, if it isn't already an array.
*
* @param input Source value
* @return An array
*/
export declare function toArray(input: Array | A): Array;
/**
* Returns `true` if `element` exists in `array`.
*
* @param array Source array
* @param element Item to search for
* @returns Item in array?
*/
export declare function has(array: ArrayLike, element: A): boolean;
/**
* Returns a shallow copy of `array`.
*
* @param array Source array
* @returns Copy of the array
*/
export declare function copy(array: ArrayLike): Array;
/**
* Returns a copy of `array` which contains all the elements between `start`
* and `end`. (including `start` and excluding `end`)
*
* If `end` is not provided, it defaults to `array.length`.
*
* @param array Source array
* @param start Start index
* @param end End index
* @returns Part of the array
*/
export declare function slice(array: ArrayLike, start: number, end?: number): Array;
/**
* Inserts a value into array at specific index.
*
* @param array Source array
* @param index Index
* @param value Value to insert
*/
export declare function insertIndex(array: Array, index: number, value: A): void;
/**
* Removes a value from array at specific index.
*
* @param array Source array
* @param index Index
*/
export declare function removeIndex(array: Array, index: number): void;
/**
* Searches the array using custom function and returns index of the item if
* found.
*
* Will call `matches` function on all items of the array. If return value
* evaluates to `true`, index is returned.
*
* Otherwise returns -1.
*
* @param array Source array
* @param matches Search function
* @returns Index of the item if found
*/
export declare function findIndex(array: ArrayLike, matches: (value: A, index: number) => boolean): number;
/**
* This is the same as `findIndex` except it searches from right to left.
*
* @param array Source array
* @param matches Search function
* @returns Index of the item if found
*/
export declare function findIndexReverse(array: ArrayLike, matches: (value: A, index: number) => boolean): number;
/**
* Returns the first item for which `matches` returns `true`, or `undefined`
* if there is none.
*
* @param array Source array
* @param matches Search function
* @returns Item if found
*/
export declare function find(array: ArrayLike, matches: (value: A, index: number) => boolean): A | undefined;
/**
* This is the same as `find` except it searches from right to left.
*
* @param array Source array
* @param matches Search function
* @returns Item if found
*/
export declare function findReverse(array: ArrayLike, matches: (value: A, index: number) => boolean): A | undefined;
/**
* Calls `matches` on each item and returns the first value it returns that is
* not `undefined`, or `undefined` if there is none.
*
* @param array Source array
* @param matches Search function
* @returns Value returned by `matches`
*/
export declare function findMap(array: ArrayLike, matches: (value: A, index: number) => B | undefined): B | undefined;
/**
* Returns a copy of `array` with its two halves taken in turn: 1, 4, 2, 5,
* 3, 6. Neighbours come from opposite halves.
*
* @ignore
*/
export declare function interleave(array: Array): Array;
/**
* Shuffles `array` in place into a random order.
*
* @param array Source array
*/
export declare function shuffle(array: Array): void;
export declare type Ordering = -1 | 0 | 1;
/**
* Result of a binary search: whether a match was found, and its index or the
* index to insert the value at.
*
* @ignore Exclude from docs
*/
export interface SortResult {
found: boolean;
index: number;
}
/**
* Binary-searches a sorted array. `ordering` returns a negative number for an
* item before the value searched for, `0` for a match and a positive number
* for an item after it. The index is that of the right-most match, or where
* the value would be inserted.
*
* @ignore Exclude from docs
* @param array Source array
* @param ordering An ordering function
* @returns Result of the search
*/
export declare function getSortedIndex(array: ArrayLike, ordering: (left: A) => Ordering): SortResult;
/**
* Same as `getSortedIndex`, except that the index is that of the left-most
* match.
*
* @ignore Exclude from docs
* @param array Source array
* @param ordering An ordering function
* @returns Result of the search
*/
export declare function getFirstSortedIndex(array: ArrayLike, ordering: (left: A) => Ordering): SortResult;
/**
* Removes in place every item for which `keep` returns `false`.
*
* @param array Source array
* @param keep Test function
*/
export declare function keepIf(array: Array, keep: (value: A) => boolean): void;
//# sourceMappingURL=Array.d.ts.map