///
/**
* Appends the `elms` to the `target` where the elms may be an array, a single object
* or an iterator object
* @group Array
* @group Iterator
* @example
* ```ts
* let theArray = arrAppend([], 1);
* arrAppend(theArray, [ 2, 3, 4 ]);
* arrAppend(theArray, [ "a", "b", "c" ]);
* // theArray is now [ 1, 2, 3, 4, "a", "b", "c" ]
* ```
* @param target - The target array
* @param elms - The item, array of items an iterable or iterator object of items to add to the target
* @returns The passed in target array
* @example
* ```ts
* // Adding a single value
* arrAppend([], undefined); // []
* arrAppend([], 0); // [ 0 ]
* arrAppend([1], undefined); // [ 1 ]
* arrAppend([1], 2); // [ 1, 2 ]
*
* // Adding an array
* arrAppend([], [] as number[]); // []
* arrAppend([], [0]); // [ 0 ]
* arrAppend([1], []); // [ 1 ]
* arrAppend([1], [2]); // [ 1, 2 ]
*
* // Adding with an iterator
* arrAppend([], ([] as number[]).values()); // []
* arrAppend([], [0].values()); // [ 0 ]
* arrAppend([1], [].keys()); // [ 1 ]
* arrAppend([1], [2].values()); // [ 1, 2 ]
* arrAppend([1], [2].keys()); // [ 1, 0 ] - 0 is from the index from the first element
* ```
*/
export declare function arrAppend(target: T[], elms: T | T[] | Iterator): T[];
/**
* The arrAt() method takes an integer value and returns the item at that index, allowing for
* positive and negative integers. Negative integers count back from the last item in the array.
* This is an ES2022 feature with polyfill support for older environments.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array-like object to get element from
* @param index - The index of the element to return. Negative index counts from the end
* @returns The element at the specified index, or undefined if index is out of range
* @example
* ```ts
* arrAt([1, 2, 3, 4, 5], 0); // 1
* arrAt([1, 2, 3, 4, 5], 2); // 3
* arrAt([1, 2, 3, 4, 5], -1); // 5
* arrAt([1, 2, 3, 4, 5], -2); // 4
* arrAt([1, 2, 3], 10); // undefined
* arrAt([1, 2, 3], -10); // undefined
*
* // Array-like objects
* arrAt({ length: 3, 0: "a", 1: "b", 2: "c" }, -1); // "c"
* ```
*/
export declare const arrAt: (theArray: ArrayLike, index: number) => T;
/**
* Deep copy handler to identify and copy arrays.
* @since 0.4.4
* @group Object - Deep Copy
* @param details - The details object for the current property being copied
* @returns `true` if the current value is a function otherwise `false`
*/
export declare function arrayDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean;
/**
* The arrChunk() method returns a new array with elements divided into groups of a specified size.
* The last group may have fewer elements if the array length is not divisible by the chunk size.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to chunk
* @param size - The size of each chunk. Must be a positive integer
* @returns A new array of chunks, where each chunk is an array of the specified size
* @example
* ```ts
* arrChunk([1, 2, 3, 4, 5, 6, 7], 2); // [[1, 2], [3, 4], [5, 6], [7]]
* arrChunk([1, 2, 3, 4, 5], 3); // [[1, 2, 3], [4, 5]]
* arrChunk([1, 2, 3], 1); // [[1], [2], [3]]
* arrChunk([1, 2, 3], 5); // [[1, 2, 3]]
* arrChunk([], 2); // []
*
* // Array-like objects
* arrChunk({ length: 5, 0: "a", 1: "b", 2: "c", 3: "d", 4: "e" }, 2);
* // [["a", "b"], ["c", "d"], ["e"]]
* ```
*/
export declare function arrChunk(theArray: ArrayLike | null | undefined, size: number): T[][];
/**
* The arrCompact() method returns a new array with all falsy values removed.
* Falsy values include: false, 0, -0, 0n, "", null, undefined, and NaN.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to compact
* @returns A new array with all falsy values filtered out
* @example
* ```ts
* arrCompact([0, 1, false, 2, "", 3, null, undefined, 4]); // [1, 2, 3, 4]
* arrCompact([false, 0, "", null, undefined]); // []
* arrCompact([1, 2, 3]); // [1, 2, 3]
* arrCompact([]); // []
*
* // Array-like objects
* arrCompact({ length: 5, 0: 0, 1: 1, 2: false, 3: 2, 4: null }); // [1, 2]
* ```
*/
export declare function arrCompact(theArray: ArrayLike | null | undefined): T[];
/**
* Alias of `Array.prototype.concat()` for consumers that prefer the `arr*` helper naming.
*
* Unlike {@link arrAppend}, this helper does NOT mutate the input arrays and returns a new array.
* @since 0.15.0
* @function
* @group Array
* @param theArray - The array to concatenate into a new array.
* @param items - Additional arrays and/or items to concatenate.
* @returns A new array containing values from `theArray` followed by each concatenated item.
* @example
* ```ts
* let values = arrConcat([1], [2, 3]);
* // values is [1, 2, 3]
*
* let next = arrConcat(values, ["a", "b"]);
* // next is [1, 2, 3, "a", "b"]
* // values is still [1, 2, 3]
* ```
* @example
* ```ts
* const left = [1, 2];
* const right = [3, 4];
* const merged = arrConcat(left, right, 5);
* // merged is [1, 2, 3, 4, 5]
* // left is still [1, 2]
* // right is still [3, 4]
* ```
*/
export declare const arrConcat: {
(theArray: T[]): T[];
(theArray: T[], ...items: ConcatArray[]): T[];
(theArray: T[], ...items: (T | ConcatArray)[]): T[];
};
/**
* The arrContains() method determines whether an array contains a certain value among its
* entries, returning true or false as appropriate.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @param theArray - The array or array like object of elements to be searched.
* @param searchElement - The value to search for
* @param fromIndex - The optional Zero-based index at which to start searching, converted to an integer.
* - Negative index counts back from the end of the array — if fromIndex \< 0, fromIndex + array.length
* is used. However, the array is still searched from front to back in this case.
* - If fromIndex \< -array.length or fromIndex is omitted, 0 is used, causing the entire array to be searched.
* - If fromIndex \>= array.length, the array is not searched and false is returned.
* @returns A boolean value which is true if the value searchElement is found within the array (or the part of
* the array indicated by the index fromIndex, if specified).
* @example
* ```ts
* arrContains([1, 2, 3], 2); // true
* arrContains([1, 2, 3], 4); // false
* arrContains([1, 2, 3], 3, 3); // false
* arrContains([1, 2, 3], 3, -1); // true
* arrContains([1, 2, NaN], NaN); // true
* arrContains(["1", "2", "3"], 3 as any); // false
*
* // Array Like
* arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 2); // true
* arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 4); // false
* arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, 3); // false
* arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, -1); // true
* arrContains({ length: 3, 0: 1, 1: 2, 2: NaN }, NaN); // true
* arrContains({ length: 3, 0: "1", 1: "2", 2: "3" }, 3 as any); // false
* ```
*/
export declare const arrContains: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => boolean;
/**
* The arrDifference() method returns a new array containing elements from the first array
* that do not exist in any of the other provided arrays. Uses strict equality (===) for comparison.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The source array to compare from
* @param excludeArrays - One or more arrays whose values should be excluded
* @returns A new array containing elements only in the source array
* @example
* ```ts
* arrDifference([1, 2, 3, 4], [2, 4]); // [1, 3]
* arrDifference([1, 2, 3], [2], [3]); // [1]
* arrDifference(["a", "b", "c"], ["b"]); // ["a", "c"]
* arrDifference([1, 2, 3], []); // [1, 2, 3]
* arrDifference([], [1, 2]); // []
*
* // Array-like objects
* arrDifference({ length: 3, 0: 1, 1: 2, 2: 3 }, [2]); // [1, 3]
* ```
*/
export declare function arrDifference(theArray: ArrayLike | null | undefined, ...excludeArrays: ArrayLike[]): T[];
/**
* The arrDrop() method returns a new array with the first n elements removed from the source array.
* If n is greater than the array length, returns empty array. If n is negative or 0, returns all elements.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to drop from
* @param count - The number of elements to drop from the beginning
* @returns A new array with the first n elements removed
* @example
* ```ts
* arrDrop([1, 2, 3, 4, 5], 2); // [3, 4, 5]
* arrDrop(["a", "b", "c"], 1); // ["b", "c"]
* arrDrop([1, 2], 5); // []
* arrDrop([1, 2, 3], 0); // [1, 2, 3]
* arrDrop([1, 2, 3], -1); // [1, 2, 3]
*
* // Array-like objects
* arrDrop({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, 2); // [3, 4]
* ```
*/
export declare function arrDrop(theArray: ArrayLike | null | undefined, count: number): T[];
/**
* The arrDropWhile() method returns a new array with elements from the beginning removed
* as long as the predicate function returns true. Once the predicate returns false,
* all remaining elements (including that one) are included in the result.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies the narrowed type when using type guards
* @param theArray - The array or array-like object to drop from
* @param callbackFn - Function to test each element. Return true to drop, false to stop dropping
* @param thisArg - Optional value to use as `this` when executing callbackFn
* @returns A new array with leading elements removed while predicate was true
* @example
* ```ts
* arrDropWhile([1, 2, 3, 4, 1], x => x < 3); // [3, 4, 1]
* arrDropWhile([2, 4, 6, 1, 8], x => x % 2 === 0); // [1, 8]
* arrDropWhile([1, 2, 3], x => x > 5); // [1, 2, 3]
* arrDropWhile([1, 2, 3], x => x < 5); // []
*
* // Array-like objects
* arrDropWhile({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, x => x < 3); // [3, 4]
* ```
*/
export declare function arrDropWhile(theArray: ArrayLike | null | undefined, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any): T[];
/**
* The arrEvery() method is an iterative method. It calls a provided callbackFn function once for
* each element in an array, until the callbackFn returns a falsy value. If such an element is found,
* arrEvery() immediately returns false and stops iterating through the array. Otherwise, if callbackFn
* returns a truthy value for all elements, every() returns true.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return `true` if the callbackFn returns a `truthy` value for every array elements. Otherwise `false`.
* @example
* ```ts
* function isBigEnough(element: T, index: number, array: T[]) {
* return element >= 10;
* }
*
* arrEvery([12, 5, 8, 130, 44], isBigEnough); // false
* arrEvery([12, 54, 18, 130, 44], isBigEnough); // true
*
* const isSubset = (array1: T[], array2: T[]) => arrEvery(array2, (element) => arrIncludes(array1, element));
*
* isSubset([1, 2, 3, 4, 5, 6, 7], [5, 7, 6]); // true
* isSubset([1, 2, 3, 4, 5, 6, 7], [5, 8, 7]); // false
*
* arrEvery([1, , 3], (x) => x !== undefined); // true
* arrEvery([2, , 2], (x) => x === 2); // true
*
* // Array Like combinations
* isSubset([1, 2, 3, 4, 5, 6, 7], { length: 3, 0: 5, 1: 7, 2: 6}); // true
* isSubset([1, 2, 3, 4, 5, 6, 7], { length: 3, 0: 5, 1: 8, 2: 7}); // false
*
* isSubset({ length: 7, 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7 }, [ 5, 7, 6 ]); // true
* isSubset({ length: 7, 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7 }, [5, 8, 7]); // false
*
* isSubset({ length: 7, 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7 }, { length: 3, 0: 5, 1: 7, 2: 6}); // true
* isSubset({ length: 7, 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7 }, { length: 3, 0: 5, 1: 8, 2: 7}); // false
* ```
*/
export declare const arrEvery: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => theArray is T[];
/**
* The arrFill() method changes all elements in an array to a static value, from a start index
* (default 0) to an end index (default array.length). It returns the modified array.
* This method mutates the array.
* @function
* @since 0.14.0
* @group Array
* @typeParam T - Identifies the type of array elements
* @param theArray - The array to fill
* @param value - Value to fill the array with
* @param start - Start index (inclusive), defaults to 0. Negative index counts from the end
* @param end - End index (exclusive), defaults to array.length. Negative index counts from the end
* @returns The modified array
* @example
* ```ts
* arrFill([1, 2, 3], 0); // [0, 0, 0]
* arrFill([1, 2, 3], 4, 1); // [1, 4, 4]
* arrFill([1, 2, 3], 5, 1, 2); // [1, 5, 3]
* arrFill([1, 2, 3], 6, -2); // [1, 6, 6]
* arrFill([1, 2, 3], 7, -3, -1); // [7, 7, 3]
* arrFill([], 1); // []
* ```
*/
export declare const arrFill: (theArray: WritableArrayLike, value: T, start?: number, end?: number) => WritableArrayLike;
/**
* The arrFilter() method creates a shallow copy of a portion of a given array, filtered down to just the elements
* from the given array that pass the test implemented by the provided function.
*
* The filter() method is an iterative method. It calls a provided callbackFn function once for each element in an
* array, and constructs a new array of all the values for which callbackFn returns a truthy value. Array elements
* which do not pass the callbackFn test are not included in the new array.
*
* `callbackFn` is invoked only for array indexes which have assigned values. It is not invoked for empty slots in
* sparse arrays.
*
* The arrFilter() method is a copying method. It does not alter this but instead returns a shallow copy that contains
* the same elements as the ones from the original array (with some filtered out). However, the function provided as
* callbackFn can mutate the array. Note, however, that the length of the array is saved before the first invocation
* of callbackFn. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFilter()
* began.
* - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.
* - If an existing, yet-unvisited element of the array is changed by callbackFn, its value passed to the `callbackFn`
* will be the value at the time that element gets visited. Deleted elements are not visited.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of the elements.
* @typeParam E - Identifies a more specific instance of the base array type.
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return A shallow copy of a portion of the given array, filtered down to just the elements from the given
* array that pass the test implemented by the provided function. If no elements pass the test, an empty array
* will be returned.
* @example
* ```ts
* function isBigEnough(value: T) {
* return value >= 10;
* }
*
* const filtered = arrFilter([12, 5, 8, 130, 44], isBigEnough);
* // filtered is [12, 130, 44]
*
* const arrayLikeFiltered = arrFilter({ length: 5, 0: 12, 1: 5, 2: 8, 3: 130, 4: 44}, isBigEnough);
* // arrayLikeFiltered is [12, 130, 44]
*
* const array = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
*
* function isPrime(num) {
* for (let i = 2; num > i; i++) {
* if (num % i === 0) {
* return false;
* }
* }
* return num > 1;
* }
*
* console.log(arrFilter(array, isPrime)); // [2, 3, 5, 7, 11, 13]
* ```
*/
export declare const arrFilter: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => T[] | E[];
/**
* The arrFind() method returns the first element in the provided array that satisfies
* the provided testing function. If no values satisfy the testing function, undefined
* is returned.
* - If you need the index of the found element in the array, use {@link arrFindIndex}.
* - If you need to find the index of a value, use arrIndexOf(). (It's similar to {@link arrFindIndex}, but
* checks each element for equality with the value instead of using a testing function.)
* - If you need to find if a value exists in an array, use {@link arrIncludes}. Again, it checks each element for
* equality with the value instead of using a testing function.
* - If you need to find if any element satisfies the provided testing function, use {@link arrSome}.
*
* The arrFind() method is an iterative method. It calls a provided `callbackFn` function once for each element
* in an array in ascending-index order, until `callbackFn` returns a truthy value. arrFind() then returns that
* element and stops iterating through the array. If callbackFn never returns a truthy value, arrFind() returns
* undefined.
*
* `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in
* sparse arrays behave the same as undefined.
*
* arrFind() does not mutate the array on which it is called, but the function provided as callbackFn can.
* Note, however, that the length of the array is saved before the first invocation of `callbackFn`. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFind() began.
* - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.
* - If an existing, yet-unvisited element of the array is changed by callbackFn, its value passed to the
* `callbackFn` will be the value at the time that element gets visited. Deleted elements are visited as if they
* were undefined.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return The first element in the array that satisfies the provided testing function. Otherwise, undefined
* is returned.
* @example
* ```ts
* const inventory = [
* { name: "apples", quantity: 2 },
* { name: "bananas", quantity: 0 },
* { name: "cherries", quantity: 5 },
* ];
*
* function isCherries(fruit) {
* return fruit.name === "cherries";
* }
*
* console.log(arrFind(inventory, isCherries));
* // { name: 'cherries', quantity: 5 }
*
* function isPrime(element, index, array) {
* let start = 2;
* while (start <= Math.sqrt(element)) {
* if (element % start++ < 1) {
* return false;
* }
* }
* return element > 1;
* }
*
* console.log(arrFind([4, 6, 8, 12], isPrime)); // undefined, not found
* console.log(arrFind([4, 5, 8, 12], isPrime)); // 5
*
* // Array Like
* console.log(arrFind({ length: 4, 0: 4, 1: 6, 2: 8, 3: 12 }, isPrime)); // undefined, not found
* console.log(arrFind({ length: 4:, 0: 4, 1: 5, 2: 8, 3: 12 }, isPrime)); // 5
* ```
*/
export declare const arrFind: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => T | E;
/**
* The arrFindIndex() method returns the index of the first element in an array that satisfies the provided testing
* function. If no elements satisfy the testing function, -1 is returned.
*
* The arrFindIndex() is an iterative method. It calls a provided callbackFn function once for each element in an
* array in ascending-index order, until callbackFn returns a truthy value. arrFindIndex() then returns the index
* of that element and stops iterating through the array. If `callbackFn` never returns a truthy value, arrFindIndex()
* returns -1.
*
* `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse
* arrays behave the same as undefined.
*
* arrFindIndex() does not mutate the array on which it is called, but the function provided as `callbackFn` can.
* Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindIndex() began.
* - Changes to already-visited indexes do not cause `callbackFn` to be invoked on them again.
* If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the `callbackFn`
* will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return The index of the first element in the array that passes the test. Otherwise, -1.
* @example
* ```ts
* const inventory: Array<{ name: string, quantity: number}> = [
* { name: "apples", quantity: 2 },
* { name: "bananas", quantity: 0 },
* { name: "cherries", quantity: 5 }
* ];
*
* function isCherries(fruit: { name: string, quantity: number}) {
* return fruit.name === "cherries";
* }
*
* arrFindIndex(inventory, isCherries); // 2
*
* function isPrime(element: number) {
* if (element % 2 === 0 || element < 2) {
* return false;
* }
*
* for (let factor = 3; factor <= Math.sqrt(element); factor += 2) {
* if (element % factor === 0) {
* return false;
* }
* }
* return true;
* }
*
* arrFindIndex([4, 6, 8, 9, 12], isPrime) // -1
* arrFindIndex([4, 6, 7, 9, 12], isPrime) // 2
*
* // Array Like
* arrFindIndex({ length: 5, 0: 4, 1: 6, 2: 8, 3: 9, 4: 12 }, isPrime) // -1
* arrFindIndex({ length: 5:, 0: 4, 1: 6, 2: 7, 3: 9, 4: 12 }, isPrime) // 2
* ```
*/
export declare const arrFindIndex: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => number;
/**
* The arrFindLast() method iterates the array in reverse order and returns the value of the first element that
* satisfies the provided testing function. If no elements satisfy the testing function, undefined is returned.
* - If you need the index of the found element in the array, use arrFindLastIndex().
* - If you need to find the index of a value, use arrLastIndexOf(). (It's similar to arrFindLastIndex(), but checks
* each element for equality with the value instead of using a testing function.)
* - If you need to find if a value exists in an array, use {@link arrIncludes}. Again, it checks each element for
* equality with the value instead of using a testing function.
* - If you need to find if any element satisfies the provided testing function, use {@link arrSome}.
*
* The arrFindLast() method is an iterative method. It calls a provided callbackFn function once for each element
* in an array in descending-index order, until callbackFn returns a truthy value. arrFindLast() then returns that
* element and stops iterating through the array. If `callbackFn` never returns a truthy value, arrFindLast() returns
* undefined.
*
* `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse
* arrays behave the same as undefined.
*
* arrFindLast() does not mutate the array on which it is called, but the function provided as `callbackFn` can.
* Note, however, that the length of the array is saved before the first invocation of `callbackFn`. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindLast() began.
* - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.
* - If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the `callbackFn`
* will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return The last element in the array that satisfies the provided testing function. Otherwise, undefined
* is returned.
* @example
* ```ts
* const inventory = [
* { name: "apples", quantity: 2 },
* { name: "bananas", quantity: 0 },
* { name: "cherries", quantity: 5 },
* ];
*
* function isCherries(fruit) {
* return fruit.name === "cherries";
* }
*
* console.log(arrFindLast(inventory, isCherries));
* // { name: 'cherries', quantity: 5 }
*
* function isPrime(element, index, array) {
* let start = 2;
* while (start <= Math.sqrt(element)) {
* if (element % start++ < 1) {
* return false;
* }
* }
* return element > 1;
* }
*
* console.log(arrFindLast([4, 6, 8, 12], isPrime)); // undefined, not found
* console.log(arrFindLast([4, 5, 7, 12], isPrime)); // 7
*
* // Array Like
* console.log(arrFindLast({ length: 4, 0: 4, 1: 6, 2: 8, 3: 12 }, isPrime)); // undefined, not found
* console.log(arrFindLast({ length: 4, 0: 4, 1: 5, 2: 7, 3: 12 }, isPrime)); // 7
* ```
*/
export declare const arrFindLast: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => T | E;
/**
* The arrFindLastIndex() method iterates the array in reverse order and returns the index of the first element that
* satisfies the provided testing function. If no elements satisfy the testing function, -1 is returned.
*
* The arrFindLastIndex() method is an iterative method. It calls a provided `callbackFn` function once for each element
* in an array in descending-index order, until callbackFn returns a truthy value. arrFindLastIndex() then returns the
* index of that element and stops iterating through the array. If callbackFn never returns a truthy value, returns -1.
*
* `callbackFn` is invoked for every index of the array, not just those with assigned values. Empty slots in sparse arrays
* behave the same as undefined.
*
* arrFindLastIndex() does not mutate the array on which it is called, but the function provided as callbackFn can.
* Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrFindLastIndex() began.
* - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.
* - If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the callbackFn
* will be the value at the time that element gets visited. Deleted elements are visited as if they were undefined.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return The index of the last (highest-index) element in the array that passes the test. Otherwise -1 if
* no matching element is found.
* @example
* ```ts
* const inventory: Array<{ name: string, quantity: number}> = [
* { name: "apples", quantity: 2 },
* { name: "bananas", quantity: 0 },
* { name: "cherries", quantity: 5 }
* ];
*
* let called = 0;
* function isCherries(fruit: { name: string, quantity: number}) {
* called++;
* return fruit.name === "cherries";
* }
*
* arrFindLastIndex(inventory, isCherries)' // 2
* // called === 1
*
* called = 0;
* function isPrime(element: number) {
* called++;
* if (element % 2 === 0 || element < 2) {
* return false;
* }
* for (let factor = 3; factor <= Math.sqrt(element); factor += 2) {
* if (element % factor === 0) {
* return false;
* }
* }
* return true;
* }
*
* arrFindLastIndex([4, 6, 8, 9, 12], isPrime); // -1
* // called === 5
*
* called = 0;
* arrFindLastIndex([4, 6, 7, 9, 12], isPrime); // 2
* // called === 3
*
* // Array Like
* called = 0;
* arrFindLastIndex({ length: 5: 0: 4, 1: 6, 2: 8, 3: 9, 4: 12 }, isPrime); // -1
* // called === 5
*
* called = 0;
* arrFindLastIndex({ length: 5: 0: 4, 1: 6, 2: 7, 3: 9, 4: 12 }, isPrime); // 2
* // called === 3
* ```
*/
export declare const arrFindLastIndex: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => number;
/**
* The arrFlatMap() method returns a new array formed by applying a mapping function to each element
* and then flattening the mapped result by one level.
*
* This is equivalent to calling `arrMap()` followed by `arrFlatten()` with a depth of 1, but it avoids
* allocating the intermediate mapped array.
*
* Use this helper when each input item may produce zero, one, or multiple output items as part of the
* mapping step. The mapped value is flattened by exactly one level: if the callback returns an array,
* its elements are appended to the output; non-array values are appended directly.
*
* To flatten already-nested data without mapping, use `arrFlatten()` instead.
*
* `callbackFn` is invoked only for indexes of the array which have assigned values. Empty slots in
* sparse arrays are skipped.
*
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @typeParam R - Identifies the type of the flattened result values, defaults to T.
* @param theArray - The array or array-like object to map and flatten.
* @param callbackFn - A function that is called for each existing element and may return either a
* single value or an array of values to flatten into the result.
* @param thisArg - The value to use as the `this` when executing the `callbackFn`.
* @returns A new array containing the mapped and flattened values.
* @example
* ```ts
* arrFlatMap([1, 2, 3], (value) => [value, value * 10]);
* // [1, 10, 2, 20, 3, 30]
*
* arrFlatMap(["one", "two"], (value) => value.split(""));
* // ["o", "n", "e", "t", "w", "o"]
*
* arrFlatMap({ length: 2, 0: "a", 1: "b" }, (value, index) => [index, value]);
* // [0, "a", 1, "b"]
*
* arrFlatMap([1, 2, 3, 4], (value) => value % 2 ? [value] : []);
* // [1, 3]
*
* arrFlatMap([1, 2], (value) => [[value, value + 10]] as any);
* // [[1, 11], [2, 12]]
* ```
*/
export declare const arrFlatMap: (theArray: ArrayLike, callbackFn: ArrFlatMapCallbackFn, thisArg?: any) => R[];
/**
* Callback signature for {@link arrFlatMap}. Each invocation may return either a single value or
* an array of values to be flattened into the result by one level.
*
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of the array elements
* @typeParam R - Identifies the type of the flattened output values, defaults to T.
* @param value - The current element being processed in the array.
* @param index - The index of the current element being processed in the array.
* @param array - The array-like object that the `flatMap` function was called on.
*/
export declare type ArrFlatMapCallbackFn = (value: T, index?: number, array?: ArrayLike) => R | ReadonlyArray;
/**
* The arrFlatten() method returns a new array with all sub-array elements flattened
* up to the specified depth (default 1).
*
* Use this helper when the input already contains nested arrays and you only need to
* control how deeply to flatten. Flattening is depth-based and only applies to values
* that are arrays; non-array values are copied into the output unchanged.
*
* For map-then-flatten workflows, use `arrFlatMap()` which always flattens mapped
* results by exactly one level.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to flatten
* @param depth - The flattening depth, defaults to 1. Use Infinity for complete flattening
* @returns A new flattened array
* @example
* ```ts
* arrFlatten([1, [2, 3], [4, [5, 6]]]); // [1, 2, 3, 4, [5, 6]]
* arrFlatten([1, [2, 3], [4, [5, 6]]], 2); // [1, 2, 3, 4, 5, 6]
* arrFlatten([1, [2, 3], [4, [5, 6]]], Infinity); // [1, 2, 3, 4, 5, 6]
* arrFlatten([1, 2, 3]); // [1, 2, 3]
* arrFlatten([]); // []
*
* // With array-like objects
* arrFlatten({ length: 2, 0: 1, 1: [2, 3] }); // [1, 2, 3]
* ```
*/
export declare function arrFlatten(theArray: ArrayLike | null | undefined, depth?: number): any[];
/**
* Calls the provided `callbackFn` function once for each element in an array in ascending index order. It is not invoked for index properties
* that have been deleted or are uninitialized. And unlike the ES6 forEach() you CAN stop or break the iteration by returning -1 from the
* `callbackFn` function.
*
* The range (number of elements) processed by arrForEach() is set before the first call to the `callbackFn`. Any elements added beyond the range
* or elements which as assigned to indexes already processed will not be visited by the `callbackFn`.
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the element type of the array
* @param theArray - The array or array like object of elements to be searched.
* @param callbackfn - A `synchronous` function that accepts up to three arguments. arrForEach calls the callbackfn function one time for each element in the array.
* @param thisArg - An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined
* the array will be used as the this value.
* @remarks
* arrForEach expects a `synchronous` function.
* arrForEach does not wait for promises. Make sure you are aware of the implications while using promises (or async functions) as forEach callback.
* @example
* ```ts
* const items = ['item1', 'item2', 'item3'];
* const copyItems = [];
*
* // before using for loop
* for (let i = 0; i < items.length; i++) {
* copyItems.push(items[i]);
* }
*
* // before using forEach()
* items.forEach((item) => {
* copyItems.push(item);
* });
*
* // after
* arrForEach(items, (item) => {
* copyItems.push(item);
* // May return -1 to abort the iteration
* });
*
* // Also supports input as an array like object
* const items = { length: 3, 0: 'item1', 1: 'item2', 2: 'item3' };
* ```
*/
export declare function arrForEach(theArray: ArrayLike, callbackfn: (value: T, index: number, array: T[]) => void | number, thisArg?: any): void;
export declare function arrForEach(theArray: ArrayLike, callbackfn: (value: T, index: number, array: ArrayLike) => void | number, thisArg?: any): void;
/**
* Creates an new shallow-copied array from an array-like object or an iterable.
* @function
* @since 0.9.7
* @group ArrayLike
* @group Array
* @group Iterator
* @typeParam T - Identifies the element type of the array-like or iterable.
* @typeParam U - Identifies returned type of the array
* @param theValue - An array-like object or iterable to convert to an array.
* @param mapFn - A {@link ArrFromMapFn | mapping function} to call on every element of the array. If provided, every
* value to be added to the array is first passed through this map function, and the return
* value is added to the array instead. The function is called with the following arguments:
* @param thisArg - Value of 'this' used to invoke the mapfn.
* @example
* ```ts
* arrFrom("Hello");
* // [ "H", "e", "l", "l", "o" ]
*
* arrFrom(new Set(["Hello", "Darkness", "my", "old", "friend"]));
* // ["Hello", "Darkness", "my", "old", "friend"]
*
* let map = new Map([
* [ 1, "Hello" ],
* [ 2, "Darkness" ],
* [ 3, "my" ],
* [ 4, "old" ],
* [ 5, "friend"]
* ]);
*
* arrFrom(map.values());
* // ["Hello", "Darkness", "my", "old", "friend"]
*
* arrFrom(map.keys());
* // [ 1, 2, 3, 4, 5 ]
*
* arrFrom(map.entries());
* // [ [ 1, "Hello" ], [ 2, "Darkness" ], [ 3, "my" ], [ 4, "old" ], [ 5, "friend"] ]
*
* // With a Mapping function
* const map = new Map([
* [ 1, "Hello" ],
* [ 2, "Darkness" ],
* [ 3, "my" ],
* [ 4, "old" ],
* [ 5, "friend"]
* ]);
*
* arrFrom(map, ([ key, value ]) => ({ [key]: value }));
* // [ {"1": "Hello"}, {"2": "Darkness"}, {"3": "my"}, {"4": "old"}, {"5": "friend"} ]
* ```
*/
export declare const arrFrom: (theValue: ArrayLike | Iterable, mapFn?: ArrFromMapFn, thisArg?: any) => U[];
/**
* Callback signature for {@link arrFrom} mapFn that is called for every element of array. Each time mapFn
* executes, the returned value is added to newArray.
*
* @since 0.9.7
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of the array elements
* @typeParam R - Identifies the type of the elements returned by the map function, defaults to T.
* @param value - The current element being processed in the array.
* @param index - The index of the current element being processed in the array.
*/
export declare type ArrFromMapFn = (value: T, index?: number) => R;
/**
* The arrGroupBy() method groups array elements by the result of a callback function,
* returning an object where keys are group identifiers and values are arrays of grouped elements.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to group
* @param callbackFn - Function that determines the group key for each element
* @param thisArg - The value to use as 'this' when executing callbackFn
* @returns An object with group keys as properties and arrays of grouped elements as values
* @example
* ```ts
* const numbers = [1, 2, 3, 4, 5, 6];
* const grouped = arrGroupBy(numbers, (n) => n % 2 === 0 ? "even" : "odd");
* // { odd: [1, 3, 5], even: [2, 4, 6] }
*
* const people = [
* { name: "Alice", age: 30 },
* { name: "Bob", age: 25 },
* { name: "Charlie", age: 30 }
* ];
* const byAge = arrGroupBy(people, (p) => p.age);
* // { "25": [{ name: "Bob", age: 25 }], "30": [{ name: "Alice", age: 30 }, { name: "Charlie", age: 30 }] }
* ```
*/
export declare function arrGroupBy(theArray: ArrayLike | null | undefined, callbackFn: ArrGroupByCallbackFn, thisArg?: any): Record;
/**
* Callback function type used by {@link arrGroupBy} to derive a group key for each element.
* The function is called once per element and must return a `string`, `number`, or `symbol`
* that identifies which group the element belongs to. Elements that map to the same key are
* collected into the same array in the result object.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param value - The current element of the array being processed.
* @param index - The zero-based index of the current element in the array.
* @param array - The array (or array-like object) that {@link arrGroupBy} was called on.
* @returns A `string`, `number`, or `symbol` that identifies the group for the current element.
* @example
* ```ts
* // Group numbers as "even" or "odd"
* const parity: ArrGroupByCallbackFn = (n) => n % 2 === 0 ? "even" : "odd";
*
* arrGroupBy([1, 2, 3, 4, 5], parity);
* // { odd: [1, 3, 5], even: [2, 4] }
* ```
* @example
* ```ts
* // Group objects by a property value
* interface Person { name: string; dept: string; }
*
* const byDept: ArrGroupByCallbackFn = (p) => p.dept;
*
* const people: Person[] = [
* { name: "Alice", dept: "eng" },
* { name: "Bob", dept: "hr" },
* { name: "Carol", dept: "eng" }
* ];
*
* arrGroupBy(people, byDept);
* // {
* // eng: [{ name: "Alice", dept: "eng" }, { name: "Carol", dept: "eng" }],
* // hr: [{ name: "Bob", dept: "hr" }]
* // }
* ```
* @example
* ```ts
* // Use the element index to create fixed-size buckets
* const bucket: ArrGroupByCallbackFn = (_v, idx) => idx % 3;
*
* arrGroupBy(["a", "b", "c", "d", "e"], bucket);
* // { 0: ["a", "d"], 1: ["b", "e"], 2: ["c"] }
* ```
*/
export declare type ArrGroupByCallbackFn = (value: T, index: number, array: ArrayLike) => string | number | symbol;
/**
* The arrIncludes() method determines whether an array includes a certain value among its
* entries, returning true or false as appropriate.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @param theArray - The array or array like object of elements to be searched.
* @param searchElement - The value to search for
* @param fromIndex - The optional Zero-based index at which to start searching, converted to an integer.
* - Negative index counts back from the end of the array — if fromIndex \< 0, fromIndex + array.length
* is used. However, the array is still searched from front to back in this case.
* - If fromIndex \< -array.length or fromIndex is omitted, 0 is used, causing the entire array to be searched.
* - If fromIndex \>= array.length, the array is not searched and false is returned.
* @returns A boolean value which is true if the value searchElement is found within the array (or the part of
* the array indicated by the index fromIndex, if specified).
* @example
* ```ts
* arrIncludes([1, 2, 3], 2); // true
* arrIncludes([1, 2, 3], 4); // false
* arrIncludes([1, 2, 3], 3, 3); // false
* arrIncludes([1, 2, 3], 3, -1); // true
* arrIncludes([1, 2, NaN], NaN); // true
* arrIncludes(["1", "2", "3"], 3 as any); // false
*
* // Array Like
* arrIncludes({ length: 3, 0: 1, 1: 2, 2: 3 }, 2); // true
* arrIncludes({ length: 3, 0: 1, 1: 2, 2: 3 }, 4); // false
* arrIncludes({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, 3); // false
* arrIncludes({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, -1); // true
* arrIncludes({ length: 3, 0: 1, 1: 2, 2: NaN }, NaN); // true
* arrIncludes({ length: 3, 0: "1", 1: "2", 2: "3" }, 3 as any); // false
* ```
*/
export declare const arrIncludes: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => boolean;
/**
* Returns only present own numeric index keys for an array-like value.
*
* Unlike {@link arrKeys}, this skips holes / missing indexes.
* For example, an array with indexes `0`, `1`, `2`, `10` returns `[0, 1, 2, 10]`.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @param value - The array-like value to enumerate.
* @returns An array containing only present own numeric index keys.
* @example
* ```ts
* arrIndexKeys(["a", "b", "c"]);
* // [0, 1, 2]
*
* const sparse: any[] = [];
* sparse[0] = "a";
* sparse[10] = "z";
* arrIndexKeys(sparse);
* // [0, 10]
* ```
*/
export declare function arrIndexKeys(value: ArrayLike): number[];
/**
* The arrIndexOf() method returns the first index at which a given element can be found in the array,
* or -1 if it is not present.
* `arrIndexOf()` compares searchElement to elements of the Array using strict equality (the same
* method used by the === or triple-equals operator).
* @function
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array like object of elements to be searched.
* @param searchElement - The element to locate in the array.
* @param fromIndex - The index to start the search at. If the index is greater than or equal to
* the array's length, -1 is returned, which means the array will not be searched. If the provided
* index value is a negative number, it is taken as the offset from the end of the array.
* Note: if the provided index is negative, the array is still searched from front to back. If the
* provided index is 0, then the whole array will be searched. Default: 0 (entire array is searched).
* @return The first index of the element in the array; -1 if not found.
* @example
* ```ts
* const array = [2, 9, 9];
* arrIndexOf(array, 2); // 0
* arrIndexOf(array, 7); // -1
* arrIndexOf(array, 9, 2); // 2
* arrIndexOf(array, 2, -1); // -1
* arrIndexOf(array, 2, -3); // 0
*
* let indices: number[] = [];
* const array = ['a', 'b', 'a', 'c', 'a', 'd'];
* const element = 'a';
* let idx = arrIndexOf(array, element);
* while (idx !== -1) {
* indices.push(idx);
* idx = arrIndexOf(array, element, idx + 1);
* }
* console.log(indices);
* // [0, 2, 4]
*
* function updateVegetablesCollection (veggies, veggie) {
* if (arrIndexOf(veggies, veggie) === -1) {
* veggies.push(veggie);
* console.log('New veggies collection is : ' + veggies);
* } else {
* console.log(veggie + ' already exists in the veggies collection.');
* }
* }
*
* let veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];
*
* updateVegetablesCollection(veggies, 'spinach');
* // New veggies collection is : potato,tomato,chillies,green-pepper,spinach
* updateVegetablesCollection(veggies, 'spinach');
* // spinach already exists in the veggies collection.
*
* // Array Like
* let arrayLike = {
* length: 3,
* 0: "potato",
* 1: "tomato",
* 2: "chillies",
* 3: "green-pepper" // Not checked as index is > length
* };
*
* arrIndexOf(arrayLike, "potato"); // 0
* arrIndexOf(arrayLike, "tomato"); // 1
* arrIndexOf(arrayLike, "chillies"); 2
* arrIndexOf(arrayLike, "green-pepper"); // -1
* ```
*/
export declare const arrIndexOf: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => number;
/**
* The arrIntersection() method returns a new array containing elements that exist in all provided arrays.
* Uses strict equality (===) for comparison and maintains order from the first array.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param arrays - Two or more arrays to intersect
* @returns A new array containing elements common to all arrays
* @example
* ```ts
* arrIntersection([1, 2, 3], [2, 3, 4]); // [2, 3]
* arrIntersection([1, 2, 3], [2, 3], [3, 4]); // [3]
* arrIntersection(["a", "b"], ["b", "c"]); // ["b"]
* arrIntersection([1, 2], [3, 4]); // []
* arrIntersection([1, 2, 3], []); // []
*
* // Array-like objects
* arrIntersection({ length: 3, 0: 1, 1: 2, 2: 3 }, [2, 3]); // [2, 3]
* ```
*/
export declare function arrIntersection(...arrays: ArrayLike[]): T[];
/**
* Returns an iterator over all numeric keys from `0` to `length - 1`.
*
* This uses `Array.prototype.keys()` when available and falls back to {@link polyArrKeys}.
* Unlike {@link arrIndexKeys}, this always iterates all index positions, including holes.
* @since 0.14.0
* @function
* @group Array
* @group ArrayLike
* @group Iterator
* @param value - The array-like value to get key iterator for.
* @returns An iterable iterator of numeric index keys.
* @example
* ```ts
* arrFrom(arrKeys(["a", "b", "c"]));
* // [0, 1, 2]
*
* const sparse: any[] = [];
* sparse[2] = "c";
* arrFrom(arrKeys(sparse));
* // [0, 1, 2]
* ```
*/
export declare const arrKeys: (value: ArrayLike) => IterableIterator;
/**
* The arrLastIndexOf() method returns the last index at which a given element can be found in the array,
* or -1 if it is not present.
* `arrLastIndexOf()` compares searchElement to elements of the Array using strict equality (the same
* method used by the === or triple-equals operator). [NaN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN)
* values are never compared as equal, so arrLastIndexOf() always returns -1 when searchElement is NaN.
*
* The arrLastIndexOf() method skips empty slots in sparse arrays.
*
* The arrLastIndexOf() method is generic. It only expects the this value to have a length property and integer-keyed properties.
*
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array like object of elements to be searched.
* @param searchElement - The element to locate in the array.
* @param fromIndex - Zero-based index at which to start searching backwards, converted to an integer.
* - Negative index counts back from the end of the array — if fromIndex \< 0, fromIndex + array.length is used.
* - If fromIndex \< -array.length, the array is not searched and -1 is returned. You can think of it conceptually
* as starting at a nonexistent position before the beginning of the array and going backwards from there. There
* are no array elements on the way, so searchElement is never found.
* - If fromIndex \>= array.length or fromIndex is omitted, array.length - 1 is used, causing the entire array to
* be searched. You can think of it conceptually as starting at a nonexistent position beyond the end of the array and going backwards from there. It eventually reaches the real end position of the array, at which point it starts searching backwards through the actual array elements.
* @return The first index of the element in the array; -1 if not found.
* @example
* ```ts
* const numbers = [2, 5, 9, 2];
* arrLastIndexOf(numbers, 2); // 3
* arrLastIndexOf(numbers, 7); // -1
* arrLastIndexOf(numbers, 2, 3); // 3
* arrLastIndexOf(numbers, 2, 2); // 0
* arrLastIndexOf(numbers, 2, -2); // 0
* arrLastIndexOf(numbers, 2, -1); // 3
*
* let indices: number[] = [];
* const array = ["a", "b", "a", "c", "a", "d"];
* const element = "a";
* let idx = arrLastIndexOf(array, element);
* while (idx !== -1) {
* indices.push(idx);
* idx = arrLastIndexOf(array, element, idx ? idx - 1 : -(array.length + 1));
* }
* console.log(indices);
* // [4, 2, 0]
*
* function updateVegetablesCollection (veggies, veggie) {
* if (arrLastIndexOf(veggies, veggie) === -1) {
* veggies.push(veggie);
* console.log('New veggies collection is : ' + veggies);
* } else {
* console.log(veggie + ' already exists in the veggies collection.');
* }
* }
*
* let veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];
*
* updateVegetablesCollection(veggies, 'spinach');
* // New veggies collection is : potato,tomato,chillies,green-pepper,spinach
* updateVegetablesCollection(veggies, 'spinach');
* // spinach already exists in the veggies collection.
*
* // Array Like
* let arrayLike = {
* length: 3,
* 0: "potato",
* 1: "tomato",
* 2: "chillies",
* 3: "green-pepper" // Not checked as index is > length
* };
*
* arrLastIndexOf(arrayLike, "potato"); // 0
* arrLastIndexOf(arrayLike, "tomato"); // 1
* arrLastIndexOf(arrayLike, "chillies"); 2
* arrLastIndexOf(arrayLike, "green-pepper"); // -1
* ```
*/
export declare const arrLastIndexOf: (theArray: ArrayLike, searchElement: T, fromIndex?: number) => number;
/**
* The arrMap() method creates a new array populated with the results of calling a provided function on every
* element in the calling array.
*
* `arrMap` calls a provided callbackFn function once for each element in an array, in order, and constructs
* a new array from the results. callbackFn is invoked only for indexes of the array which have assigned
* values (including undefined).
*
* It is not called for missing elements of the array; that is:
* - indexes that have never been set;
* - indexes which have been deleted.
*
* @function
* @since 0.3.3
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of the array elements
* @typeParam R - Identifies the type of the elements returned by the callback function, defaults to T.
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - The function that is called for evetn element of `theArray`.
* @param thisArg - The value to use as the `this` when executing the `callbackFn`.
* @example
* ```ts
* const numbers = [1, 4, 9];
* const roots = arrMap(numbers, (num) => Math.sqrt(num));
*
* // roots is now [1, 2, 3]
* // numbers is still [1, 4, 9]
*
* const kvArray = [{ key: 1, value: 10 },
* { key: 2, value: 20 },
* { key: 3, value: 30 }];
*
* const reformattedArray = arrMap(kvArray, ({ key, value}) => ({ [key]: value }));
*
* // reformattedArray is now [{1: 10}, {2: 20}, {3: 30}],
*
* // kvArray is still:
* // [{key: 1, value: 10},
* // {key: 2, value: 20},
* // {key: 3, value: 30}]
*
* // Also supports Array Like objects with same output
* const kvArray = {
* length: 3,
* 0: { key: 1, value: 10 },
* 1: { key: 2, value: 20 },
* 2: { key: 3, value: 30 }
* };
* ```
*/
export declare const arrMap: (theArray: ArrayLike, callbackFn: ArrMapCallbackFn, thisArg?: any) => R[];
/**
* Callback signature for {@link arrMap} that is called for every element of array. Each time callbackFn
* executes, the returned value is added to newArray.
*
* @since 0.3.3
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of the array elements
* @typeParam R - Identifies the type of the elements returned by the callback function, defaults to T.
* @param value - The current element being processed in the array.
* @param index - The index of the current element being processed in the array.
* @param array - The array that the `map` function was called on.
*/
export declare type ArrMapCallbackFn = (value: T, index?: number, array?: T[]) => R;
/**
* The arrPartition() method splits an array into two arrays based on a predicate function.
* The first array contains elements for which the predicate returns true, the second contains the rest.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies the narrowed type when using type guards
* @param theArray - The array or array-like object to partition
* @param callbackFn - Function to test each element. Return true to include in first array, false for second
* @param thisArg - Optional value to use as `this` when executing callbackFn
* @returns A tuple of two arrays: [matching elements, non-matching elements]
* @example
* ```ts
* arrPartition([1, 2, 3, 4, 5], x => x % 2 === 0); // [[2, 4], [1, 3, 5]]
* arrPartition(["a", "bb", "ccc"], x => x.length > 1); // [["bb", "ccc"], ["a"]]
*
* // With type guard
* const mixed: (string | number)[] = [1, "a", 2, "b"];
* const [strings, numbers] = arrPartition(mixed, (x): x is string => typeof x === "string");
* // strings: string[], numbers: (string | number)[]
*
* // Array-like objects
* arrPartition({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, x => x > 2); // [[3, 4], [1, 2]]
* ```
*/
export declare function arrPartition(theArray: ArrayLike | null | undefined, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any): [T[] | E[], T[]];
/**
* The `ArrPredicateCallbackFn` function is used for {@link arrEvery} and {@link arrFilter},
* it should return a `truthy` value to indicate a matching element has been found.
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @typeParam E - Identifies the type of the return array elements (defaults to T)
* @param value - The current element of the array being processed.
* @param index - The index of the current element of the array being processed.
* @param array - The array being processed.
* @returns A boolean value indicating that the value is of the type expected (the test is true)
*/
export declare type ArrPredicateCallbackFn = (value: T, index: number, array: T[]) => value is E;
/**
* The `ArrPredicateCallbackFn2` function is used for {@link arrEvery} and {@link arrFilter},
* it should return a `truthy` value to indicate a matching element has been found.
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @typeParam E - Identifies the type of the return array elements (defaults to T)
* @param value - The current element of the array being processed.
* @param index - The index of the current element of the array being processed.
* @param array - The array being processed.
*/
export declare type ArrPredicateCallbackFn2 = (value: T, index: number, array: T[]) => unknown;
/**
* The arrReduce() method executes a user-supplied "reducer" callback function on each element of the array,
* in order, passing in the return value from the calculation on the preceding element. The final result of
* running the reducer across all elements of the array is a single value.
*
* The first time that the callback is run there is no "return value of the previous calculation". If supplied,
* an initial value may be used in its place. Otherwise the array element at index 0 is used as the initial
* value and iteration starts from the next element (index 1 instead of index 0).
* @function
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array like object of elements to be searched.
* @param callbackfn - A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue - If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
* @returns The value that results from running the "reducer" callback function to completion over the entire array.
* @example
* ```ts
* const getMax = (a: number, b: number) => Math.max(a, b);
*
* // callback is invoked for each element in the array starting at index 0
* arrReduce([1, 100], getMax, 50); // 100
* arrReduce([ 50], getMax, 10); // 50
*
* // callback is invoked once for element at index 1
* arrReduce([1, 100], getMax); // 100
*
* // callback is not invoked
* arrReduce([ 50], getMax); // 50
* arrReduce([ ], getMax, 1); // 1
*
* arrReduce([ ], getMax); // throws TypeError
*
* // Also supports Array like objects
* arrReduce({ length: 2, 0: 1, 1: 100 }, getMax, 50); // 100
* arrReduce({ length: 1, 0: 50 }, getMax, 10); // 50
*
* // callback is invoked once for element at index 1
* arrReduce({ length: 2, 0: 1, 1: 100 }, getMax); // 100
*
* // callback is not invoked
* arrReduce({ length: 1, 0: 50 }, getMax); // 50
* arrReduce({ length: 0 }, getMax, 1); // 1
* ```
*/
export declare const arrReduce: (theArray: ArrayLike, callbackfn: ArrReduceCallbackFn, initialValue?: T | R) => R;
/**
* The `reducer` function called for {@link arrReduce}.
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @typeParam R - Identifies the type of the return array elements (defaults to T)
* @param previousValue - The value resulting from the previous call to callbackFn. On first call, initialValue if
* specified, otherwise the value of array[0].
* @param currentValue - The value of the current element. On first call, the value of array[0] if an initialValue
* was specified, otherwise the value of array[1].
* @param currentIndex - The index position of currentValue in the array. On first call, 0 if initialValue was
* specified, otherwise 1.
* @param array -The array being traversed.
*/
export declare type ArrReduceCallbackFn = (previousValue: T | R, currentValue: T, currentIndex: number, array: T[]) => R;
/**
* The arrReverse() method reverses an array in place and returns the reference to the same array.
* The first array element becomes the last, and the last array element becomes the first.
* If you want to reverse an array without modifying the original, use arrSlice() first.
* @function
* @since 0.14.0
* @group Array
* @param theArray - The array to reverse
* @returns The reversed array (same reference as input)
* @example
* ```ts
* const arr1 = [1, 2, 3];
* arrReverse(arr1); // [3, 2, 1]
* // arr1 is now [3, 2, 1]
*
* arrReverse(["a", "b", "c"]); // ["c", "b", "a"]
* arrReverse([1]); // [1]
* arrReverse([]); // []
*
* // Non-mutating usage
* const original = [1, 2, 3];
* const reversed = arrReverse(arrSlice(original));
* // original: [1, 2, 3], reversed: [3, 2, 1]
* ```
*/
export declare const arrReverse: (theArray: WritableArrayLike) => WritableArrayLike;
/**
* The arrRotate() method returns a new array with elements rotated by the specified number of positions.
* Positive values rotate left (elements shift forward), negative values rotate right
* (elements shift backward). The original array is not modified.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array-like object to rotate
* @param count - Number of positions to rotate. Positive = right, negative = left
* @returns A new array with elements rotated
* @example
* ```ts
* arrRotate([1, 2, 3, 4, 5], 2); // [3, 4, 5, 1, 2]
* arrRotate([1, 2, 3, 4, 5], -2); // [4, 5, 1, 2, 3]
* arrRotate([1, 2, 3], 0); // [1, 2, 3]
* arrRotate([1, 2, 3], 3); // [1, 2, 3] (full rotation)
* arrRotate([1, 2, 3], 5); // [3, 1, 2] (wraps around)
* arrRotate([1, 2, 3], -5); // [2, 3, 1] (wraps around)
* arrRotate([], 3); // []
*
* // Array-like objects
* arrRotate({ length: 3, 0: "a", 1: "b", 2: "c" }, 1); // ["b", "c", "a"]
* ```
*/
export declare function arrRotate(theArray: ArrayLike | null | undefined, count: number): T[];
/**
* The arrSample() method returns a random element from the array.
* Returns undefined if the array is empty or null/undefined.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to sample from
* @returns A random element from the array, or undefined if empty
* @example
* ```ts
* arrSample([1, 2, 3, 4, 5]); // e.g., 3
* arrSample(["a", "b", "c"]); // e.g., "b"
* arrSample([42]); // 42
* arrSample([]); // undefined
* arrSample(null); // undefined
*
* // Array-like objects
* arrSample({ length: 3, 0: "x", 1: "y", 2: "z" }); // e.g., "y"
* ```
*/
export declare function arrSample(theArray: ArrayLike | null | undefined): T | undefined;
/**
* The arrShuffle() method returns a new array with elements randomly shuffled.
* Uses the Fisher-Yates shuffle algorithm for uniform randomization.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to shuffle
* @returns A new array with elements in random order
* @example
* ```ts
* arrShuffle([1, 2, 3, 4, 5]); // e.g., [3, 1, 5, 2, 4]
* arrShuffle(["a", "b", "c"]); // e.g., ["c", "a", "b"]
* arrShuffle([1]); // [1]
* arrShuffle([]); // []
*
* // Array-like objects
* arrShuffle({ length: 3, 0: "x", 1: "y", 2: "z" }); // e.g., ["z", "x", "y"]
* ```
*/
export declare function arrShuffle(theArray: ArrayLike | null | undefined): T[];
/**
* The arrSlice() method returns a shallow copy of a portion of an array into a new array object
* selected from start to end (end not included) where start and end represent the index of items
* in that array. The original array will not be modified.
*
* The `arrSlice()` method is a copying method. It does not alter this but instead returns a shallow
* copy that contains some of the same elements as the ones from the original array.
*
* The `arrSlice()` method preserves empty slots. If the sliced portion is sparse, the returned arra
* is sparse as well.
*
* The `arrSlice()` method is generic. It only expects the this value to have a length property and
* integer-keyed properties.
*
* For both start and end, a negative index can be used to indicate an offset from the end of the array.
* For example, -2 refers to the second to last element of the array.
* @since 0.9.3
* @group Array
* @group ArrayLike
* @param start - Zero-based index at which to start extraction, converted to an integer.
* - Negative index counts back from the end of the array — if start \< 0, start + array.length is used.
* - If start \< -array.length or start is omitted, 0 is used.
* - If start \>= array.length, nothing is extracted.
* @param end - Zero-based index at which to end extraction, converted to an integer. slice() extracts
* up to but not including end.
* - Negative index counts back from the end of the array — if end \< 0, end + array.length is used.
* - If end \< -array.length, 0 is used.
* - If end \>= array.length or end is omitted, array.length is used, causing all elements until the
* end to be extracted.
* - If end is positioned before or at start after normalization, nothing is extracted.
* @example
* ```ts
* const lyrics = ["Hello", "Darkness", "my", "old", "friend.", "I've", "come", "to", "talk" ];
*
* arrSlice(lyrics); // [ "Hello", "Darkness", "my", "old", "friend.", "I've", "come", "to", "talk" ]
* arrSlice(lyrics, 1, 3); // [ "Darkness", "my" ]
* arrSlicw(lyrics, 2); // [ "my", "old", "friend.", "I've", "come", "to", "talk" ]
* arrSlice(lyrics, 2, 4); // [ "my", "old" ]
* arrSlice(lyrics, 1, 5); // [ "Darkness", "my", "old", "friend." ]
* arrSlice(lyrics, -2); // [ "to", "talk" ]
* arrSlice(lyrics, 2, -1); // [ "my", "old", "friend.", "I've", "come", "to" ]
* ```
*/
export declare function arrSlice(theArray: ArrayLike, start?: number, end?: number): T[];
/**
* The arrSome() method tests whether at least one element in the array passes the test implemented by the
* provided function. It returns true if, in the array, it finds an element for which the provided function
* returns true; otherwise it returns false. It doesn't modify the array.
*
* The arrSome() method is an iterative method. It calls a provided `callbackFn` function once for each element
* in an array, until the `callbackFn` returns a truthy value. If such an element is found, arrSome() immediately
* returns true and stops iterating through the array. Otherwise, if callbackFn returns a falsy value for all
* elements, some() returns false.
*
* arrSome() acts like the "there exists" quantifier in mathematics. In particular, for an empty array, it
* returns false for any condition.
*
* `callbackFn` is invoked only for array indexes which have assigned values. It is not invoked for empty slots
* in sparse arrays.
*
* arrSome() does not mutate the array on which it is called, but the function provided as callbackFn can.
* Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:
* - `callbackFn` will not visit any elements added beyond the array's initial length when the call to arrSome() began.
* - Changes to already-visited indexes do not cause callbackFn to be invoked on them again.
* - If an existing, yet-unvisited element of the array is changed by `callbackFn`, its value passed to the
* `callbackFn` will be the value at the time that element gets visited. Deleted elements are not visited.
* - The arrSome() method is generic. It only expects the this value to have a length property and integer-keyed properties.
* @function
* @since 0.8.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies a more specific instance of the base array type
* @param theArray - The array or array like object of elements to be searched.
* @param callbackFn - A function that accepts up to three arguments of type {@link ArrPredicateCallbackFn} or
* {@link ArrPredicateCallbackFn2}. The predicate function is called for each element in the thArray until
* the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
* @param thisArg - A value to use as this when executing callbackFn. Defaults to the array if not provided.
* @return `true` if the callback function returns a truthy value for at least one element in the array.
* Otherwise, `false`.
*/
export declare const arrSome: (theArray: ArrayLike, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any) => boolean;
/**
* The arrTake() method returns a new array with the first n elements from the source array.
* If n is greater than the array length, returns all elements. If n is negative or 0, returns empty array.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to take from
* @param count - The number of elements to take from the beginning
* @returns A new array containing the first n elements
* @example
* ```ts
* arrTake([1, 2, 3, 4, 5], 3); // [1, 2, 3]
* arrTake(["a", "b", "c"], 2); // ["a", "b"]
* arrTake([1, 2], 5); // [1, 2]
* arrTake([1, 2, 3], 0); // []
* arrTake([1, 2, 3], -1); // []
*
* // Array-like objects
* arrTake({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, 2); // [1, 2]
* ```
*/
export declare function arrTake(theArray: ArrayLike | null | undefined, count: number): T[];
/**
* The arrTakeWhile() method returns a new array containing elements from the beginning of the array
* as long as the predicate function returns true. Once the predicate returns false, iteration stops.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @typeParam E - Identifies the narrowed type when using type guards
* @param theArray - The array or array-like object to take from
* @param callbackFn - Function to test each element. Return true to continue, false to stop
* @param thisArg - Optional value to use as `this` when executing callbackFn
* @returns A new array containing elements until the predicate returns false
* @example
* ```ts
* arrTakeWhile([1, 2, 3, 4, 1], x => x < 3); // [1, 2]
* arrTakeWhile([2, 4, 6, 1, 8], x => x % 2 === 0); // [2, 4, 6]
* arrTakeWhile([1, 2, 3], x => x > 5); // []
* arrTakeWhile([1, 2, 3], x => x < 5); // [1, 2, 3]
*
* // Array-like objects
* arrTakeWhile({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, x => x < 3); // [1, 2]
* ```
*/
export declare function arrTakeWhile(theArray: ArrayLike | null | undefined, callbackFn: ArrPredicateCallbackFn | ArrPredicateCallbackFn2, thisArg?: any): T[] | E[];
/**
* Creates an object map from array-like, iterator or iterable values.
*
* Keys are generated in stable source order via `keySelector`; later duplicate keys overwrite earlier values.
* Unsafe keys (`__proto__`, `constructor`, `prototype`) are ignored.
* @since 0.15.0
* @group Array
* @example
* ```ts
* const users = [
* { id: "u1", name: "Ada" },
* { id: "u2", name: "Lin" },
* { id: "u1", name: "Ada Updated" }
* ];
*
* arrToMap(users, (value) => value.id, (value) => value.name);
* // { u1: "Ada Updated", u2: "Lin" }
* ```
*/
export declare function arrToMap(values: ArrayLike | Iterator | Iterable, keySelector: ArrToMapKeySelectorFn): {
[key: string]: T;
};
export declare function arrToMap(values: ArrayLike | Iterator | Iterable, keySelector: ArrToMapKeySelectorFn, valueSelector: ArrToMapValueSelectorFn): {
[key: string]: V;
};
/**
* Callback signature for key selection in {@link arrToMap}.
* @since 0.15.0
* @group Array
* @example
* ```ts
* const byId: ArrToMapKeySelectorFn<{ id: string }> = (value) => value.id;
* ```
*/
export declare type ArrToMapKeySelectorFn = (value: T, index: number) => string | number;
/**
* Callback signature for value selection in {@link arrToMap}.
* @since 0.15.0
* @group Array
* @example
* ```ts
* const pickName: ArrToMapValueSelectorFn<{ name: string }, string> = (value) => value.name;
* ```
*/
export declare type ArrToMapValueSelectorFn = (value: T, index: number) => V;
/**
* The arrUnion() method returns a new array containing all unique elements from all provided arrays.
* Uses strict equality (===) for comparison and maintains insertion order.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param arrays - One or more arrays to combine
* @returns A new array containing all unique elements from all arrays
* @example
* ```ts
* arrUnion([1, 2], [2, 3]); // [1, 2, 3]
* arrUnion([1, 2], [3, 4], [4, 5]); // [1, 2, 3, 4, 5]
* arrUnion(["a", "b"], ["b", "c"]); // ["a", "b", "c"]
* arrUnion([1, 1, 2], [2, 2, 3]); // [1, 2, 3]
* arrUnion([], [1, 2]); // [1, 2]
*
* // Array-like objects
* arrUnion({ length: 2, 0: 1, 1: 2 }, [2, 3]); // [1, 2, 3]
* ```
*/
export declare function arrUnion(...arrays: ArrayLike[]): T[];
/**
* The arrUnique() method returns a new array with duplicate elements removed.
* Uses strict equality (===) for comparison and maintains insertion order.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the base type of array elements
* @param theArray - The array or array-like object to remove duplicates from
* @returns A new array with duplicate values removed, preserving order of first occurrence
* @example
* ```ts
* arrUnique([1, 2, 2, 3, 1, 4]); // [1, 2, 3, 4]
* arrUnique(["a", "b", "a", "c"]); // ["a", "b", "c"]
* arrUnique([1, "1", 1, "1"]); // [1, "1"]
* arrUnique([]); // []
* arrUnique([1]); // [1]
*
* // Array-like objects
* arrUnique({ length: 4, 0: 1, 1: 2, 2: 2, 3: 3 }); // [1, 2, 3]
* ```
*/
export declare function arrUnique(theArray: ArrayLike | null | undefined): T[];
/**
* The arrUnzip() method reverses the operation of arrZip(). Given an array of grouped elements,
* it creates multiple arrays where each contains elements from the same position in each group.
* This is the inverse operation of arrZip().
* @since 0.14.0
* @group Array
* @group ArrayLike
* @param theArray - An array of arrays to unzip
* @returns An array of arrays, ungrouped by position
* @example
* ```ts
* arrUnzip([[1, "a"], [2, "b"], [3, "c"]]); // [[1, 2, 3], ["a", "b", "c"]]
* arrUnzip([[1, "a", true], [2, "b", false]]); // [[1, 2], ["a", "b"], [true, false]]
* arrUnzip([[1], [2], [3]]); // [[1, 2, 3]]
* arrUnzip([]); // []
*
* // Array-like objects
* arrUnzip({ length: 2, 0: [1, "x"], 1: [2, "y"] }); // [[1, 2], ["x", "y"]]
* ```
*/
export declare function arrUnzip(theArray: ArrayLike> | null | undefined): any[][];
/**
* The arrWith() method is the copying version of using the bracket notation to change the value
* of a given index. It returns a new array with the element at the given index replaced with the
* given value. This is an ES2023 feature with polyfill support for older environments.
* @function
* @since 0.14.0
* @group Array
* @group ArrayLike
* @typeParam T - Identifies the type of array elements
* @param theArray - The array or array-like object to copy from
* @param index - The index at which to change the value. Negative index counts from the end
* @param value - The new value to set at the index
* @returns A new array with the element at index replaced, or the original array if index is out of range
* @example
* ```ts
* arrWith([1, 2, 3], 1, 5); // [1, 5, 3]
* arrWith([1, 2, 3], -1, 5); // [1, 2, 5]
* arrWith([1, 2, 3], -2, 5); // [1, 5, 3]
* arrWith([1, 2, 3], 10, 5); // RangeError (out of bounds)
*
* const original = [1, 2, 3];
* const modified = arrWith(original, 1, 9);
* // original: [1, 2, 3], modified: [1, 9, 3]
*
* // Array-like objects
* arrWith({ length: 3, 0: "a", 1: "b", 2: "c" }, 1, "x"); // ["a", "x", "c"]
* ```
*/
export declare const arrWith: (theArray: ArrayLike, index: number, value: T) => T[];
/**
* The arrZip() method creates a new array of grouped elements, where the first array contains
* the first elements of each input array, the second array contains the second elements, and so on.
* The length of the result is determined by the shortest input array.
* @since 0.14.0
* @group Array
* @group ArrayLike
* @param arrays - Two or more arrays to zip together
* @returns A new array of arrays, grouped by index
* @example
* ```ts
* arrZip([1, 2, 3], ["a", "b", "c"]); // [[1, "a"], [2, "b"], [3, "c"]]
* arrZip([1, 2], ["a", "b", "c"]); // [[1, "a"], [2, "b"]]
* arrZip([1, 2, 3], ["a", "b"], [true, false]); // [[1, "a", true], [2, "b", false]]
* arrZip([1], []); // []
*
* // Array-like objects
* arrZip({ length: 2, 0: 1, 1: 2 }, ["x", "y"]); // [[1, "x"], [2, "y"]]
* ```
*/
export declare function arrZip(...arrays: ArrayLike[]): any[][];
/**
* The asString() method returns a string representing the value by
* explicitly using `String(`value`)`.
*
* @function
* @since 0.4.3
* @group String
* @group Conversion
* @group Value
* @param value - The value to get a string representation of
* @example
* ```ts
* const arr = [ 1, 2, 3];
* asString(arr); // "1,2,3"
* asString(null); // "null"
* asString(undefined); // "undefined"
* asString(42); // "42"
* asString(Symbol.for("Hello")); // "Symbol(Hello)"
* ```
*/
export declare const asString: (value: any) => string;
/**
* Produces the return type for a function after a prefix of arguments has already been bound.
*
* This implementation is a TypeScript 3.4+ compatible middle ground between:
* 1. A fully simplified fallback (`(...args: any[]) => ReturnType`)
* 2. A TS 4.0+ variadic tuple implementation (shown below as comments)
*
* It preserves remaining argument inference for up to 5 pre-bound arguments and then
* falls back to a generic callable return type.
* @since 0.15.0
* @group Funcs
* @typeParam TFn - The function being bound.
* @typeParam TArgs - The tuple of arguments that will be pre-bound.
*/
export declare type BoundFunction any, TArgs extends any[]> = TArgs extends [] ? TFn : TArgs extends [any] ? (TFn extends (a0: any, ...args: infer R) => infer RT ? (...args: R) => RT : (...args: any[]) => ReturnType) : TArgs extends [any, any] ? (TFn extends (a0: any, a1: any, ...args: infer R) => infer RT ? (...args: R) => RT : (...args: any[]) => ReturnType) : TArgs extends [any, any, any] ? (TFn extends (a0: any, a1: any, a2: any, ...args: infer R) => infer RT ? (...args: R) => RT : (...args: any[]) => ReturnType) : TArgs extends [any, any, any, any] ? (TFn extends (a0: any, a1: any, a2: any, a3: any, ...args: infer R) => infer RT ? (...args: R) => RT : (...args: any[]) => ReturnType) : TArgs extends [any, any, any, any, any] ? (TFn extends (a0: any, a1: any, a2: any, a3: any, a4: any, ...args: infer R) => infer RT ? (...args: R) => RT : (...args: any[]) => ReturnType) : (...args: any[]) => ReturnType;
/**
* Type alias for the global `cancelIdleCallback` function, which cancels a previously
* scheduled idle callback. Using a type alias makes it easier to reference and annotate
* the function, and supports older TypeScript versions that may not include the global
* declaration.
*
* When using {@link scheduleIdleCallback} you can cancel the scheduled work through the
* returned {@link ITimerHandler} instead of calling `cancelIdleCallback` directly.
* Use this type (via {@link getCancelIdleCallback}) only when you need the raw browser API.
* @since 0.11.2
* @group Timer
* @group Idle
* @group Environment
* @param handle - The handle returned by `requestIdleCallback` that identifies the idle
* callback to cancel. Passing an invalid or already-consumed handle is a no-op.
* @example
* ```ts
* // Schedule then immediately cancel an idle callback
* const reqIdle = getIdleCallback();
* const cancelIdle: CancelIdleCallback | null = getCancelIdleCallback();
*
* if (reqIdle && cancelIdle) {
* const handle = reqIdle((deadline) => {
* // background work
* });
*
* // cancel before the callback fires
* cancelIdle(handle);
* }
* ```
* @example
* ```ts
* // Store a typed reference for later use
* let _cancelIdle: CancelIdleCallback | null = null;
*
* function ensureCancelIdle(): CancelIdleCallback | null {
* return _cancelIdle || (_cancelIdle = getCancelIdleCallback());
* }
* ```
*/
export declare type CancelIdleCallback = (handle: number) => void;
/**
* The signatire of the function to override clearing a previous timeout created with the {@link TimeoutOverrideFn}, it will be passed
* the result returned from the {@link TimeoutOverrideFn} call.
* @since 0.4.5
* @group Timer
* @param timeoutId - The value returned from the previous {@link TimeoutOverrideFn}.
*/
export declare type ClearTimeoutOverrideFn = (timeoutId: number | any) => void;
/**
* Create an iterator which is backed by the provided array, unlike a normal
* array iterators where the array cannot be modified function creates
* a shallow copy of the array using `slice()` so that you are free to modify
* the original array.
*
* This will still return an iterator if the provided `values` is null or
* undefined which will result in no entries.
* @since 0.4.2
* @group Iterator
* @param values - The source array to create an iterator from
* @returns A new iterator
* @example
* ```ts
* let cnt = 0;
* let values = [];
* iterForOf(createArrayIterator([10, 20, 5, 15]), (value) => {
* cnt++;
* values.push(value);
* });
* ```
*/
export declare function createArrayIterator(values: T[]): Iterator;
/**
* Create and return a readonly {@link ICachedValue} instance that is populated with the provided value.
* This is useful when you want to cache a previously fetched value and return it without having to re-fetch
* it again.
* This is a lightweight version of {@link getLazy} which does not support any expiration or invalidation,
* it also will not honor the {@link setBypassLazyCache} setting and will always return the provided value.
* @since 0.10.5
* @group Helpers
* @group Cache
* @typeParam T - The type of the value to be cached
* @param value - The value to cache
* @returns A new {@link ICachedValue} instance which wraps the provided value
* @example
* ```ts
* let cachedValue = createCachedValue("some value");
* // cachedValue.v === "some value"
*
* JSON.stringify(cachedValue) === '{"v":"some value"}';
* ```
*/
export declare function createCachedValue(value: T): ICachedValue;
/**
* Create a Custom Error class which may be used to throw custom errors.
* @group Error
* @param name - The name of the Custom Error
* @param constructCb - [Optional] An optional callback function to call when a
* new Custom Error instance is being created. (Since v0.16.0) The callback is invoked with `this` bound to
* the same instance that is also passed as the `self` (1st) argument, so implementations may use either
* `this.prop = ...` or `self.prop = ...` interchangeably - this only applies when `constructCb` is a normal
* (non-arrow) function, as arrow functions ignore the bound `this` and keep their own lexically captured value.
* The 3rd argument, `isOwnInstance`, is `true` when this class is the leaf-most (most-derived) type actually
* being instantiated (eg. `new ThisClass()`), and `false` when this class's own constructor is only running
* because it is a base class of some other custom error further down an inheritance chain (eg. `new SomeSubClass()`,
* where `SomeSubClass` was created via `createCustomError(..., ThisClass)`). Use this to skip work - such as
* your own stack-trace capture - that only the leaf-most instance actually needs, since a base class's own
* construction step runs (and would otherwise redo that work) for every instance of every one of its subclasses too.
* @param errorBase - [Optional] (since v0.9.6) The error class to extend for this class, defaults to Error.
* @param superArgsFn - [Optional] (since v0.13.0) An optional function that receives the constructor arguments and
* returns the arguments to pass to the base class constructor. When not provided all constructor
* arguments are forwarded to the base class. Use this to support a different argument order or
* to pass a subset of arguments to the base class (similar to calling `super(...)` in a class).
* @returns A new Error `class`
* @example
* ```ts
* import { createCustomError, isError } from "@nevware21/ts-utils";
*
* // For an error that just contains a message
* let myCustomErrorError = createCustomError("MessageError");
*
* try {
* throw new myCustomErrorError("Error Message!");
* } catch(e) {
* // e.name === MessageError
* // isError(e) === true;
* // Object.prototype.toString.call(e) === "[object Error]";
* }
*
* // Or a more complex error object
* interface MyCriticalErrorConstructor extends CustomErrorConstructor {
* new(message: string, file: string, line: number, col: number): MyCriticalError;
* (message: string, file: string, line: number, col: number): MyCriticalError;
* }
*
* interface MyCriticalError extends Error {
* readonly errorId: number;
* readonly args: any[]; // Holds all of the arguments passed during construction
* }
*
* let _totalErrors = 0;
* let myCustomError = createCustomError("CriticalError", (self, args) => {
* _totalErrors++;
* self.errorId = _totalErrors;
* self.args = args;
* });
*
* try {
* throw new myCustomError("Not Again!");
* } catch(e) {
* // e.name === CriticalError
* // isError(e) === true;
* // Object.prototype.toString.call(e) === "[object Error]";
* }
*
* // ----------------------------------------------------------
* // Extending another custom error class
* // ----------------------------------------------------------
*
* let AppError = createCustomError("ApplicationError");
* let theAppError = new appError();
*
* isError(theAppError); // true
* theAppError instanceof Error; // true
* theAppError instanceof AppError; // true
*
* let StartupError = createCustomError("StartupError", null, AppError);
* let theStartupError = new StartupError();
*
* isError(theStartupError); // true
* theStartupError instanceof Error; // true
* theStartupError instanceof AppError; // true
* theStartupError instanceof StartupError; // true
*
* // ----------------------------------------------------------
* // Custom error with reordered / transformed arguments
* // (the superArgsFn maps constructor args to base class args)
* // ----------------------------------------------------------
*
* interface HttpErrorConstructor extends CustomErrorConstructor {
* new(statusCode: number, message: string): HttpError;
* (statusCode: number, message: string): HttpError;
* }
*
* interface HttpError extends Error {
* readonly statusCode: number;
* }
*
* // HttpError takes (statusCode, message) but base Error expects (message)
* let MyHttpError = createCustomError("HttpError",
* (self, args) => {
* self.statusCode = args[0];
* },
* Error,
* (args) => [ args[1] ] // pass only the message to base Error constructor
* );
*
* let err = new MyHttpError(404, "Not Found");
* err.message; // "Not Found"
* err.statusCode; // 404
* ```
*/
export declare function createCustomError(name: string, constructCb?: ((this: any, self: any, args: IArguments, isOwnInstance?: boolean) => void) | null, errorBase?: B, superArgsFn?: ((args: IArguments) => ArrayLike) | null): T;
/**
* Create and return a readonly {@link ICachedValue} instance which will cache and return the value returned
* by the callback function. The callback function will only be called once, multiple access of the value
* will not cause re-execution of the callback as the result from the first call is cached internally.
* This is a lightweight version of {@link getLazy} which does not support any expiration or invalidation,
* it also will not honor the {@link setBypassLazyCache} setting and will always return the provided value.
* @remarks Since 0.12.3 this is now an alias for {@link getDeferred}, it is recommended to use that function
* directly instead of this one.
* @since 0.10.5
* @group Helpers
* @group Cache
* @function
* @typeParam T - The type of the value to be cached
* @param cb - The callback function to fetch the value to be lazily evaluated and cached
* @returns
*/
export declare const createDeferredCachedValue: (cb: () => T) => ICachedValue;
/**
* Create a TypeScript style enum class which is a mapping that maps from the key -\> value and the value -\> key.
* This is effectively the same as defining a non-constant enum, but this only repeats the "Name" of the enum value once.
* @group Enum
* @example
* ```ts
* const enum Animal {
* Dog = 0,
* Cat = 1,
* Butterfly = 2,
* Bear = 3
* }
* const Animals = createEnum({
* Dog: Animal.Dog,
* Cat: Animal.Cat,
* Butterfly: Animal.Butterfly,
* Bear: Animal.Bear
* });
* // You end up with an object that maps everything to the name
* Animals.Dog === 0; // true
* Animals[0] === "Dog"; // true
* Animals["Dog"] === 0; // true
* Animals.Cat === 1; // true
* Animals[1] === "Cat"; // true
* Animals["Cat"] === 1; // true
* ```
* @param values - The values to populate on the new object
* @typeParam E - Identifies the const enum type being mapped
* @returns A new frozen (immutable) object which looks and acts like a TypeScript Enum class.
*/
export declare function createEnum(values: {
[key in keyof E]: E[keyof E];
}): EnumCls;
/**
* Create a map object which contains both the property key and value which both map to the key,
* E[key] =\> key and E[value] =\> key.
* @group Enum
* @example
* ```ts
* const enum Animal {
* Dog = 0,
* Cat = 1,
* Butterfly = 2,
* Bear = 3
* }
* const animalMap = createEnumKeyMap({
* Dog: Animal.Dog,
* Cat: Animal.Cat,
* Butterfly: Animal.Butterfly,
* Bear: Animal.Bear
* });
* // You end up with an object that maps everything to the name
* animalMap.Dog === "Dog"; // true
* animalMap[0] === "Dog"; // true
* animalMap["Dog"] === "Dog"; // true
* animalMap.Cat === "Cat"; // true
* animalMap[1] === "Cat"; // true
* animalMap["Cat"] === "Cat"; // true
* // Helper function to always return the "Name" of the type of animal
* function getAnimalType(type: string | number | Animal) {
* return animalMap[type];
* }
* ```
* @param values - The values to populate on the new object
* @typeParam E - Identifies the const enum type being mapped
* @returns A new frozen (immutable) object which contains a property for each key and value that returns the value.
*/
export declare function createEnumKeyMap(values: {
[key in keyof E]: E[keyof E];
}): EnumNameMap;
/**
* Create a map object which contains both the perperty key and value which both map to the resulting value,
* E[key] =\> value and E[value] =\> value.
* @group Enum
* @example
* ```ts
* const enum Animal {
* Dog = 0,
* Cat = 1,
* Butterfly = 2,
* Bear = 3
* }
* const animalMap = createEnumValueMap({
* Dog: Animal.Dog,
* Cat: Animal.Cat,
* Butterfly: Animal.Butterfly,
* Bear: Animal.Bear
* });
* // You end up with an object that maps everything to the name
* animalMap.Dog === 0; // true
* animalMap[0] === 0; // true
* animalMap["Dog"] === 0; // true
* animalMap.Cat === 1; // true
* animalMap[1] === 1; // true
* animalMap["Cat"] === 1; // true
*
* // Helper function to always return the "Name" of the type of animal
* function getAnimalValue(type: string | number | Animal) {
* return animalMap[type];
* }
* ```
* @param values - The values to populate on the new object
* @typeParam E - Identifies the const enum type being mapped
* @returns A new frozen (immutable) object which contains a property for each key and value that returns the value.
*/
export declare function createEnumValueMap(values: {
[key in keyof E]: E[keyof E];
}): EnumValueMap;
/**
* Create a simple filename style regular expression from the string value, converting any embedded
* filename wildcard characters `'*'` and `'?'`.
* If the source string contains folder seperators both `'/'` and `'\'` are treated as synonomous.
* Each wildcard match will be captured as it's own group.
* The supported matching values are
* - `'*'` Matches any characters zero or more times (including folder seperators '`'/`' or `'\'`)
* - `'?'` Matches any single character once only (including folder seperators `'/'` or `'\'`)
* - `'/'` Matches either `'/'` or `'\'` character, not captured as a group
* - `'\'` Matches either `'/'` or `'\'` character, not captured as a group
*
* @since 0.9.0
* @group RegExp
* @param value - The string value to converted
* @param ignoreCase - Flag to indicate whether the regular expression should be case-sensitive, Defaults
* to false.
* @param fullMatch - Flag to identify whether the RegExp should be wrapped with `'^'` and `'$'` to
* incidate match the entire string only.
* @returns The new Regular Expression created from the provided value.
* @example
* ```ts
* let regex = createFilenameRegex("*.txt");
*
* lat matches = regex.exec("Hello");
* matches; // null
*
* let matches = regex.exec("ug.txt");
* matches[0]; // "ug.txt"
* matches[1]; // "ug"
*
* let matches = regex.exec(" ug.txt ");
* matches[0]; // " ug.txt"
* matches[1]; // " ug"
*
* let matches = regex.exec("C:\\temp\\ug.txt");
* matches[0]; // "C:\\temp\\ug.txt"
* matches[1]; // "C:\\temp\\ug"
*
* let matches = regex.exec("/var/log/ug.txt");
* matches[0]; // "/var/log/ug.txt"
* matches[1]; // "/var/log/ug"
* ```
*/
export declare function createFilenameRegex(value: string, ignoreCase?: boolean, fullMatch?: boolean): RegExp;
/**
* Create a deferred proxy function which will call the named function of the result of the hostFn, this enables
* creating bound functions which when called call the proxy the function to a different host (this) instance.
*
* This is different from `fnBind` which is provided with the concrete function and `this` instances, while the proxy
* will lazily obtain the `this` and the function is obtained by looking up the named function from the returned
* host (`this`) instance.
*
* @since 0.9.8
* @group Function
* @param hostFn - A function to get the current host and thisArg that will be called
* @param funcName - The name of the function to call on the host
* @returns The result of calling the function with the specified `this` value and arguments.
* @example
* ```ts
* const module1 = {
* prefix: "Hello",
* x: 21,
* getX() {
* return this.x;
* },
* log(value: string) {
* return this.prefix + " " + value + " : " + this.x
* }
* };
*
* // The 'this' parameter of 'getX' is bound to 'module'.
* module1.getX(); // 21
* module1.log("Darkness"); // Hello Darkness : 21
*
* // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
* let module2 = {
* prefix: "my",
* x: 42
* };
*
* let getHost = () => {
* return module1;
* };
*
* let deferredFn = createFnDeferredProxy(getHost, "getX");
*
* deferredFn(); // 21
*
* module2.defX = deferredFn;
*
* module2.defX(); // 21
* ```
*/
export declare function createFnDeferredProxy any>(hostFn: () => H, funcName: TypeFuncNames): F;
/**
* Create an iterable which conforms to the `Iterable` protocol, it uses the provided `ctx` to
* create an `Iterator` via {@link createIterator}.
*
* @see [Iterable protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol)
* @since 0.4.2
* @group Iterator
* @typeParam T - Identifies the type that will be returned by the iterator
* @param ctx - The context used to manage the iteration over the items.
* @returns A new Iterable instance
* @example
* ```ts
* let current = 0;
* let next = 1;
* let done = false;
* let fibCtx: CreateIteratorContext = {
* n: function() {
* fibCtx.v = current;
* current = next;
* next = fibCtx.v + next;
*
* // Return not done
* return false;
* },
* r: function(value) {
* done = true;
* return value;
* }
* };
*
* let values: number[] = [];
* iterForOf(createIterable(fibCtx), (value) => {
* values.push(value);
* if (values.length === 10) {
* return -1;
* }
* });
*
* // Done is true
* // done === true
* // Values: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
* ```
*/
export declare function createIterable(ctx: CreateIteratorContext): Iterable;
/**
* Create an iterable iterator which conforms to both the `Iterator` and `Iterable` protocols,
* it uses the provided `ctx` to manage moving to the `next` value and can be used directly in
* `for...of` loops or consumed via `.next()` calls.
*
* The returned object satisfies both protocols: its `[Symbol.iterator]()` method returns itself,
* making it usable anywhere an `Iterable` is expected, while also exposing the `next()` method
* of the `Iterator` protocol.
*
* @see [Iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol)
* @see [Iterable protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol)
* @since 0.14.0
* @group Iterator
* @typeParam T - Identifies the type that will be returned by the iterator
* @param ctx - The context used to manage the iteration over the items.
* @returns A new IterableIterator instance
* @example
* ```ts
* let idx = -1;
* let theValues = [ 5, 10, 15, 20, 25, 30 ];
*
* let theIterator = createIterableIterator({
* n: function() {
* idx++;
* let isDone = idx >= theValues.length;
* if (!isDone) {
* this.v = theValues[idx];
* }
* return isDone;
* }
* });
*
* // Can be consumed as an iterator
* theIterator.next(); // { value: 5, done: false }
*
* // Or used in a for...of loop (Iterable protocol)
* let values: number[] = [];
* for (const value of theIterator) {
* values.push(value);
* }
* // Values: [10, 15, 20, 25, 30]
* ```
*/
export declare function createIterableIterator(ctx: CreateIteratorContext): IterableIterator;
/**
* Create an iterator which conforms to the `Iterator` protocol, it uses the provided `ctx` to
* managed moving to the `next`.
*
* @see [Iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol)
* @since 0.4.2
* @group Iterator
* @typeParam T - Identifies the type that will be returned by the iterator
* @param ctx - The context used to manage the iteration over the items.
* @returns A new Iterator instance
* @example
* ```ts
* let idx = -1;
* let theValues = [ 5, 10, 15, 20, 25, 30 ];
*
* function getNextFn() {
* idx++;
* let isDone = idx >= theValues.length;
* if (!isDone) {
* // this is passed as the current iterator
* // so you can directly assign the next "value" that will be returned
* this.v = theValues[idx];
* }
*
* return isDone;
* }
*
* let theIterator = createIterator({ n: getNextFn });
*
* let values: number[] = [];
* iterForOf(theIterator, (value) => {
* values.push(value);
* });
*
* // Values: [5, 10, 15, 20, 25, 30 ]
* ```
*/
export declare function createIterator(ctx: CreateIteratorContext): Iterator;
/**
* The context used to manage how the {@link createIterator} returns and moves to the next item,
* and provides to the current value `v`.
* @since 0.4.2
* @group Iterator
*/
export declare interface CreateIteratorContext {
/**
* A function that returns a boolean to indicate whether it was able to produce
* the next value in the sequence. It should return `true` when the sequence is done.
* @param args - Optional additional arguments that where passed to the iterator `next` function.
* @return `false` if a new value was produced and assigned to the `v` of the context, otherwise
* `true` to indicate that the sequence is done.
*/
n: (...args: any) => boolean;
/**
* The current value to be assigned to the returned iterator result, the next `n`
* function should assign this value to the context as part of incrementing to
* the next value.
*/
v?: T;
/**
* Optional function that accepts zero or one argument. This function is called via the
* iterator `return` function when the iterator caller does not intend to make any more
* `next()` calls so the implementation and can perform any cleanup actions.
* @return [Optional] value to be included in the final iteration result
*/
r?: (value?: T) => T | undefined;
/**
* A function that accepts zero or one argument. The function is called via the iterator
* `throw` function when that the iterator caller detects an error condition, and e is
* typically an Error instance.
* @return [Optional] value to be included in the final iteration result
*/
t?: (e?: any) => T | undefined;
}
/**
* Create a regular expression that escapes all special regex characters in the input string,
* treating it as a literal string to match.
* @since 0.14.0
* @group RegExp
* @param matcher - The string value to be escaped and converted into a RegExp for literal matching.
* @returns A new Regular Expression that matches the literal string value.
* @example
* ```ts
* let regex = createLiteralRegex("Hello.World");
*
* let matches = regex.exec("Hello.World");
* matches[0]; // "Hello.World"
*
* let matches = regex.exec("HelloXWorld");
* matches; // null - dot does not match as wildcard
*
* let regex = createLiteralRegex("(test)");
* let matches = regex.exec("(test)");
* matches[0]; // "(test)"
*
* let matches = regex.exec("test");
* matches; // null
* ```
*/
export declare function createLiteralRegex(matcher: string): RegExp;
/**
* Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
*
* @since 0.9.8
* @group Function
* @param target - The target object to be assigned with the source properties and functions
* @param host - The host instance or a function to return the host instance which contains the
* functions and will be assigned as the `this` for the function being called.
* @param funcDefs - An array of function definitions on how each named function will be
* proxied onto the target.
* @return The original target after all proxies have been assigned
* @example
* ```ts
* let test = {
* x: 21,
* func1() {
* return this.x;
* }
* };
*
* test.func1(); // 21
* let newTarget = createProxyFuncs({} as any, test, [
* { n: "func1" },
* { n: "func1", as: "aliasFn" }
* ]);
*
* newTarget.func1(); // 21
* newTarget.aliasFn(); // 21
*
* newTarget.x = 42;
*
* // The return is still using the `this.x` from the original `test` as it's proxied
* newTarget.func1(); // 21
* newTarget.aliasFn(); // 21
*
* let getHostFn = () => {
* return test;
* };
*
* newTarget = createProxyFuncs({} as any, getHostFn, [
* { n: "func1" },
* { n: "func1", as: "aliasFn" }
* ]);
*
* newTarget.func1(); // 21
* newTarget.aliasFn(); // 21
*
* newTarget.x = 42;
*
* // The return is still using the `this.x` from the original `test` as it's proxied
* newTarget.func1(); // 21
* newTarget.aliasFn(); // 21
* ```
*/
export declare function createProxyFuncs(target: T, host: H | (() => H), funcDefs: ProxyFunctionDef[]): T;
/**
* Create a simple range iterator which will return an iterator that increments it's value from
* `start` to `end` by the `step`.
* - If `end` is omitted, null or undefined the value will be set to `start`
* - If the `step` value is omitted, null, undefined or zero then it will default to 1 if end \> start otherwise -1.
*
* @since 0.4.2
* @group Iterator
* @param start - The initial value of the numeric iterator
* @param end - The inclusive maximum (or minimum when moving backwards) value of the iterator.
* @param step - The step size for each iteration, may be positive or negative. Defaults to 1 when
* start \<= end and -1 when start \> end. Zero is treated as not provided.
* @returns A new iterator which will return a numeric value between start and end at step intervals
* @example
* ```ts
* let cnt = 0;
* iterForOf(createRangeIterator(0, -1, 1), (value) => {
* // Will never get called as -1 < 0
* });
*
* cnt = 0;
* let values: number[] = [];
* iterForOf(createRangeIterator(1, 1), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 1
* // values: [ 1 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(10, null as any), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 1
* // values: [ 10 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(-10, undefined as any), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 1
* // values: [ -10 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(5, 20, 5), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 4
* // values: [ 5, 10, 15, 20 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(20, 5, -5), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 4
* // values: [ 20, 15, 10, 5 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(20, 15), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 6
* // values: [ 20, 19, 18, 17, 16, 15 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(-1, 1), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 3;
* // values: [ -1, 0, 1 ]
*
* cnt = 0;
* values = [];
* iterForOf(createRangeIterator(1, -1), (value) => {
* cnt++;
* values.push(value);
* });
* // cnt === 3;
* // values: [ 1, 0, -1 ]
* ```
*/
export declare function createRangeIterator(start: number, end: number, step?: number): Iterator;
/**
* Create a map object which contains both the perperty key and value which both map to the requested
* generic mapValue with a type of V, E[key] =\> mapValue and E[value] =\> mapValue.
* @group Enum
* @example
* ```ts
* const enum Animal {
* Dog = 0,
* Cat = 1,
* Butterfly = 2,
* Bear = 3
* };
* // Creates a simple mapping to a string value
* const animalFamilyMap = createValueMap({
* Dog: [ Animal.Dog, "Canidae"],
* Cat: [ Animal.Cat, "Felidae"],
* Butterfly: [ Animal.Butterfly, "Papilionidae"],
* Bear: [ Animal.Bear, "Ursidae"]
* });
* // You end up with an object that maps everything to the name
* animalMap.Dog === "Canidae"; // true with typeof animalMap.Dog is "string"
* animalMap[0] === "Canidae"; // true with typeof animalMap[0] is "string"
* animalMap["Dog"] === "Canidae"; // true with typeof animalMap["Dog"] is "string"
* animalMap.Cat === "Felidae"; // true with typeof animalMap.Cat is "string"
* animalMap[1] === "Felidae"; // true with typeof animalMap[1] is "string"
* animalMap["Cat"] === "Felidae"; // true with typeof animalMap["Cat"] is "string"
* ```
* @param values - The values to populate on the new object
* @typeParam E - Identifies the const enum type (eg. typeof Animal);
* @typeParam V - Identifies the type of the mapping `string`; `number`; etc is not restructed to primitive types.
* @returns A new frozen (immutable) object which contains a property for each key and value that returns the defiend mapped value.
*/
export declare function createSimpleMap(values: {
[key in keyof E]: [E[keyof E], V];
}): EnumTypeMap;
/**
* Creates a non-running (paused) timer which will execute a function or specified piece of code when enabled and the timer expires,
* this is simular to using `scheduleTimeout` but the timer is not enabled (running) and you MUST call `refresh` to start the timer.
*
* The timer may be cancelled (cleared) by calling the `cancel()` function on the returned {@link ITimerHandler}, or
* you can "reschedule" and/or "restart" the timer by calling the `refresh()` function on the returned {@link ITimerHandler}
* instance
*
* @since 0.7.0
* @group Timer
*
* @param callback - The function to be executed after the timer expires.
* @param timeout - The time, in milliseconds that the timer should wait before the specified
* function or code is executed. If this parameter is omitted, a value of 0 is used, meaning
* execute "immediately", or more accurately, the next event cycle.
* @param args - Additional arguments which are passed through to the function specified by `callback`.
* @returns A {@link ITimerHandler} instance which can be used to cancel the timeout.
* @example
* ```ts
* let timeoutCalled = false;
* let theTimeout = createTimeout(() => {
* // This callback will be called after 100ms as this uses setTimeout()
* timeoutCalled = true;
* }, 100);
*
* // As the timer is not started you will need to call "refresh" to start the timer
* theTimeout.refresh();
*
* // or set enabled to true
* theTimeout.enabled = true;
* ```
*/
export declare function createTimeout(callback: (...args: A) => void, timeout: number, ...args: A): ITimerHandler;
/**
* Creates a non-running (paused) timer which will execute a function or specified piece of code when enabled once the timer expires.
* The overrideFn will be used to create the timer, this is simular to using `scheduleTimeoutWith` but the timer is not enabled (running)
* and you MUST call `refresh` to start the timer.
*
* The timer may be cancelled (cleared) by calling the `cancel()` function on the returned {@link ITimerHandler}, or
* you can "reschedule" and/or "restart" the timer by calling the `refresh()` function on the returned {@link ITimerHandler}
* instance
*
* @since 0.7.0
* @group Timer
*
* @param overrideFn - setTimeout override function this will be called instead of the `setTimeout`, if the value
* of `overrideFn` is null or undefined it will revert back to the native `setTimeout`. May also be an array with contains
* both the setTimeout and clearTimeout override functions, if either is not provided the default native functions will be used
* @param callback - The function to be executed after the timer expires.
* @param timeout - The time, in milliseconds that the timer should wait before the specified
* function or code is executed. If this parameter is omitted, a value of 0 is used, meaning
* execute "immediately", or more accurately, the next event cycle.
* @param args - Additional arguments which are passed through to the function specified by `callback`.
* @returns A {@link ITimerHandler} instance which can be used to cancel the timeout.
* @example
* ```ts
* let timeoutCalled = false;
* // Your own "setTimeout" implementation to allow you to perform additional operations or possible wrap
* // the callback to add timings.
* function newSetTimeoutFn(callback: TimeoutOverrideFn) {
* overrideCalled ++;
* return setTimeout(callback, timeout);
* }
*
* let theTimeout = createTimeoutWith(newSetTimeoutFn, () => {
* // This callback will be called after 100ms as this uses setTimeout()
* timeoutCalled = true;
* }, 100);
*
* // As the timer is not started you will need to call "refresh" to start the timer
* theTimeout.refresh();
*
* // or set enabled to true
* theTimeout.enabled = true;
* ```
* @example
* ```ts
* let timeoutCalled = false;
* // Your own "setTimeout" implementation to allow you to perform additional operations or possible wrap
* // the callback to add timings.
* function newSetTimeoutFn(callback: TimeoutOverrideFn) {
* overrideCalled ++;
* return setTimeout(callback, timeout);
* }
*
* // Your own "clearTimeout" implementation to allow you to perform additional operations or possible wrap
* // the callback to add timings.
* function newClearTimeoutFn(timeoutId: number) {
* overrideCalled ++;
* return clearTimeout( timeout);
* }
*
* let theTimeout = createTimeoutWith([newSetTimeoutFn, newClearTimeoutFn], () => {
* // This callback will be called after 100ms as this uses setTimeout()
* timeoutCalled = true;
* }, 100);
*
* // As the timer is not started you will need to call "refresh" to start the timer
* theTimeout.refresh();
*
* // or set enabled to true
* theTimeout.enabled = true;
* ```
*/
export declare function createTimeoutWith(overrideFn: TimeoutOverrideFn | TimeoutOverrideFuncs, callback: (...args: A) => void, timeout: number, ...args: A): ITimerHandler;
/**
* Create a strongly types map object which contains both the perperty key and value which both map
* to the requested mapValue,
* E[key] =\> mapValue and E[value] =\> mapValue.
* - E = the const enum type (typeof Animal);
* - V = Identifies the valid values for the keys, this should include both the enum numeric and string key of the type. The
* resulting "Value" of each entry identifies the valid values withing the assignments.
* @group Enum
* @example
* ```ts
* // Create a strongly types map
* const animalFamilyMap = createTypeMap({
* Dog: [ Animal.Dog, "Canidae"],
* Cat: [ Animal.Cat, "Felidae"],
* Butterfly: [ Animal.Butterfly, "Papilionidae"],
* Bear: [ Animal.Bear, "Ursidae"]
* });
* // You end up with a strongly types result for each value
* animalMap.Dog === "Canidae"; // true with typeof animalMap.Dog is (const) "Canidae"
* animalMap[0] === "Canidae"; // true with typeof animalMap[0] is "Canidae"
* animalMap["Dog"] === "Canidae"; // true with typeof animalMap["Dog"] is "Canidae"
* animalMap.Cat === "Felidae"; // true with typeof animalMap.Cat is "Felidae"
* animalMap[1] === "Felidae"; // true with typeof animalMap[1] is "Felidae"
* animalMap["Cat"] === "Felidae"; // true with typeof animalMap["Cat"] is "Felidae"
*
* or using an interface to define the direct string mappings
*
* interface IAnimalFamilyMap {
* Dog: "Canidae",
* Cat: "Felidae",
* Butterfly: "Papilionidae",
* Bear: "Ursidae"
* }
*
* // Create a strongly types map
* const animalFamilyMap = createTypeMap({
* Dog: [ Animal.Dog, "Canidae"],
* Cat: [ Animal.Cat, "Felidae"],
* Butterfly: [ Animal.Butterfly, "Papilionidae"],
* Bear: [ Animal.Bear, "Ursidae"]
* });
*
* // You also end up with a strongly types result for each value
* animalMap.Dog === "Canidae"; // true with typeof animalMap.Dog is (const) "Canidae"
* animalMap[0] === "Canidae"; // true with typeof animalMap[0] is "Canidae"
* animalMap["Dog"] === "Canidae"; // true with typeof animalMap["Dog"] is "Canidae"
* animalMap.Cat === "Felidae"; // true with typeof animalMap.Cat is "Felidae"
* animalMap[1] === "Felidae"; // true with typeof animalMap[1] is "Felidae"
* animalMap["Cat"] === "Felidae"; // true with typeof animalMap["Cat"] is "Felidae"
* ```
* @param values - The values to populate on the new object
* @typeParam E - Identifies the enum type
* @typeParam T - Identifies the return type that is being created via the mapping.
* @returns A new frozen (immutable) object which contains a property for each key and value that returns the defined mapped value.
*/
export declare function createTypeMap(values: {
[key in keyof E]: [E[keyof E], T[keyof T]];
}): T;
/**
* Create a simple wildcard regular expression from the string value, converting any embedded wildcard
* `'*'` characters to match any character zero or more times (including folder seperators `'/'` or `'\'`),
* while escaping all other characters.
* The supported matching values are
* - `'*'` Matches any characters zero or more times (including folder seperators '`'/`' or `'\'`)
* @since 0.9.0
* @group RegExp
* @param value - The value to be converted into a RegExp, if the value is not a string it will coerced
* to a string.
* @param ignoreCase - Flag to indicate whether the regular expression should be case-sensitive, Defaults
* to false.
* @param fullMatch - Flag to identify whether the RegExp should be wrapped with `'^'` and `'$'` to
* incidate match the entire string only.
* @returns The new Regular Expression created from the provided value.
* @example
* ```ts
* let regex = createWildcardRegex("Hello*");
*
* let matches = regex.exec("Hello");
* matches[0]; // "Hello";
* matches[1]; // ""
*
* let matches = regex.exec("Hello Darkness");
* matches[0]; // "Hello Darkness"
* matches[1]; // " Darkness"
*
* let matches = regex.exec("Darkness Hello");
* matches[0]; // "Hello"
* matches[1]; // ""
*
* let regex.exec("Darkness Hello.");
* matches[0]; // "Hello."
* matches[1]; // "."
* ```
*/
export declare function createWildcardRegex(value: string, ignoreCase?: boolean, fullMatch?: boolean): RegExp;
/**
* Defines the definition of the custom error constructor
* Used by: {@link createCustomError}
* @group Error
*/
export declare interface CustomErrorConstructor extends ErrorConstructor {
new (message?: string): T;
(message?: string): T;
readonly prototype: T;
}
/**
* Deep copy handler to identify and copy Date instances.
* @since 0.4.4
* @group Object - Deep Copy
* @param details - The details object for the current property being copied
* @returns `true` if the current value is a function otherwise `false`
*/
export declare function dateDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean;
/**
* Decode a Base64 encoded string
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The Base64 encoded string to decode
* @returns The decoded string
* @example
* ```ts
* decodeBase64("SGVsbG8="); // "Hello"
* decodeBase64("SGVsbG8gV29ybGQ="); // "Hello World"
* decodeBase64(""); // ""
* ```
*/
export declare function decodeBase64(value: string): string;
/**
* Decode a URL-safe Base64 encoded string
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The URL-safe Base64 encoded string to decode
* @returns The decoded string
* @example
* ```ts
* decodeBase64Url("SGVsbG8"); // "Hello"
* decodeBase64Url("LSsvLw"); // "+++///"
* ```
*/
export declare function decodeBase64Url(value: string): string;
/**
* Decode a hexadecimal encoded string
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The hexadecimal encoded string to decode
* @returns The decoded string
* @example
* ```ts
* decodeHex("48656c6c6f"); // "Hello"
* decodeHex("41"); // "A"
* decodeHex(""); // ""
* ```
*/
export declare function decodeHex(value: string): string;
/**
* Decode a URI encoded string
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The URI encoded string to decode
* @returns The decoded string
* @example
* ```ts
* decodeUri("Hello%20World"); // "Hello World"
* decodeUri("a%2Bb%3Dc"); // "a+b=c"
* ```
*/
export declare function decodeUri(value: string): string;
/**
* Create a new object by merging the passed arguments, this is effectively the same as calling `objExtend({}, ...theArgs)` where
* all of the arguments are added to a new object that is returned.
* @group Object
* @param target - The original object to be extended.
* @param theArgs - The optional number of arguments to be copied
* @returns - A new object or the original
*/
export declare function deepExtend(target: T, ...theArgs: any): T & any;
/**
* Represents a recursive partial type where all nested properties are optional.
* @since 0.14.0
* @group Helpers
* @typeParam T - The type to transform.
* @example
* ```ts
* interface User {
* name: string;
* address: {
* street: string;
* city: string;
* };
* }
*
* // All nested properties become optional
* function updateUser(id: number, patch: DeepPartial) { }
*
* updateUser(1, { address: { city: "Seattle" } }); // OK — street is not required
* ```
*/
export declare type DeepPartial = T extends Function ? T : T extends ReadonlyArray ? ReadonlyArray> : T extends object ? {
[P in keyof T]?: DeepPartial;
} : T;
/**
* Represents a recursive readonly type where all nested properties are readonly.
* @since 0.14.0
* @group Helpers
* @typeParam T - The type to transform.
* @example
* ```ts
* interface Config {
* server: {
* host: string;
* port: number;
* };
* }
*
* const cfg: DeepReadonly = { server: { host: "localhost", port: 8080 } };
*
* // cfg.server.host = "example.com"; // Error: cannot assign to a read-only property
* ```
*/
export declare type DeepReadonly = T extends Function ? T : T extends ReadonlyArray ? ReadonlyArray> : T extends object ? {
readonly [P in keyof T]: DeepReadonly;
} : T;
/**
* Represents a recursive required type where all nested properties are required.
* @since 0.14.0
* @group Helpers
* @typeParam T - The type to transform.
* @example
* ```ts
* interface Options {
* timeout?: number;
* retry?: {
* count?: number;
* delay?: number;
* };
* }
*
* // After applying defaults every field is guaranteed to be present
* function withDefaults(opts: Options): DeepRequired {
* return {
* timeout: opts.timeout ?? 5000,
* retry: {
* count: opts.retry?.count ?? 3,
* delay: opts.retry?.delay ?? 1000
* }
* };
* }
* ```
*/
export declare type DeepRequired = T extends Function ? T : T extends ReadonlyArray ? ReadonlyArray>> : T extends object ? {
[P in keyof T]-?: DeepRequired>;
} : NonNullable;
/**
* Returns string representation of an object suitable for diagnostics logging.
* @group Error
* @group Diagnostic
* @param object - The object to be converted to a diagnostic string value
* @param format - Identifies whether the JSON value should be formated
* - `true` - Format with 4 spaces
* - 'number' - The number of spaces to format with
* - `false` (or not Truthy) - Do not format
* @returns A string representation of the object suitable for diagnostics logging
* @example
* ```ts
* let obj = { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } };
*
* let objStr = dumpObj(obj);
* // objStr === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let objStrFmt = dumpObj(obj, true);
* // objStrFmt === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
*
* let objStrFmt2 = dumpObj(obj, 2);
* // objStrFmt2 === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
*
* let objStrFmt3 = dumpObj(obj, 0);
* // objStrFmt3 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let objStrFmt4 = dumpObj(obj, false);
* // objStrFmt4 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let objStrFmt5 = dumpObj(obj, null);
* // objStrFmt5 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let objStrFmt6 = dumpObj(obj, undefined);
* // objStrFmt6 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let objStrFmt7 = dumpObj(obj, "");
* // objStrFmt7 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
*
* let err = new Error("Hello Darkness");
* let errStr = dumpObj(err);
* // errStr === "[object Error]: { stack: 'Error: Hello Darkness\n at :1:13', message: 'Hello Darkness', name: 'Error'"
*
* let errStrFmt = dumpObj(err, true);
* // errStrFmt === "[object Error]: {\n stack: "Error: Hello Darkness\n at :1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
*
* let errStrFmt2 = dumpObj(err, 2);
* // errStrFmt2 === "[object Error]: {\n stack: "Error: Hello Darkness\n at :1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
*
* let errStrFmt3 = dumpObj(err, 0);
* // errStrFmt3 === "[object Error]: { stack: "Error: Hello Darkness\n at :1:13", message: "Hello Darkness", name: "Error" }"
*
* ```
* @see {@link dumpObj}
*/
export declare function dumpObj(object: any, format?: boolean | number): string;
/**
* Return the number of milliseconds that have elapsed since the provided `startTime`
* the `startTime` MUST be obtained from {@link perfNow} to ensure the correct elapsed
* value is returned.
*
* @since 0.4.4
* @group Timer
*
* @param startTime - The startTime obtained from `perfNow`
* @returns The number of milliseconds that have elapsed since the startTime.
* @example
* ```ts
* let start = perfNow();
* // Do some work
* let totalTime = elapsedTime(start);
* ```
*/
export declare function elapsedTime(startTime: number): number;
/**
* Encode a string value as Base64
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The string value to encode
* @returns The Base64 encoded string
* @example
* ```ts
* encodeAsBase64("Hello"); // "SGVsbG8="
* encodeAsBase64("Hello World"); // "SGVsbG8gV29ybGQ="
* encodeAsBase64(""); // ""
* ```
*/
export declare function encodeAsBase64(value: string): string;
/**
* Encode a string as URL-safe Base64
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The string value to encode
* @returns The URL-safe Base64 encoded string (replaces + with -, / with _, removes padding)
* @example
* ```ts
* encodeAsBase64Url("Hello"); // "SGVsbG8"
* encodeAsBase64Url("+++///"); // "LSsvLw"
* ```
*/
export declare function encodeAsBase64Url(value: string): string;
/**
* Encode a string as hexadecimal
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The string value to encode
* @returns The hexadecimal encoded string
* @example
* ```ts
* encodeAsHex("Hello"); // "48656c6c6f"
* encodeAsHex("A"); // "41"
* encodeAsHex(""); // ""
* ```
*/
export declare function encodeAsHex(value: string): string;
/**
* Encode the provided string to a safe HTML form, converting the base `&`, `<`, `>`, `\"` and `'`
* characters into their HTML encoded representations
* @since 0.9.0
* @group Conversion
* @group Value
* @param value - The string value to be converted into a HTML safe form
* @returns The converted string as HTML
* @example
* ```ts
* encodeAsHtml("HelloDarkness"); // "HelloDarkness"
* encodeAsHtml("Hello Darkness"); // "Hello Darkness"
* encodeAsHtml("hello.Darkness"); // "hello.Darkness"
* encodeAsHtml("hello-Darkness"); // "hello-Darkness"
* encodeAsHtml("hello_Darkness"); // "hello_Darkness"
* encodeAsHtml("abc-123"); // "abc-123"
* encodeAsHtml("0abc0"); // "0abc0"
* encodeAsHtml("\"HelloDarkness\""); // ""HelloDarkness""
* encodeAsHtml("\"Hello Darkness\""); // ""Hello Darkness""
* encodeAsHtml("\"hello Darkness\""); // ""hello Darkness""
* encodeAsHtml("\"hello Darkness\""); // ""hello Darkness""
* encodeAsHtml("\"hello .,#<[]>Darkness\""); // ""hello .,#<[]>Darkness""
* encodeAsHtml(""); // "<script src="javascript:alert('Hello');"></script>"
* ```
*/
export declare function encodeAsHtml(value: string): string;
/**
* Encode the value into a JSON string, if the provided value is a string this will encode
* any character that is not an alpha, numeric, space or some special characters as `\uXXXX`
* and will always be returned wrapped in double quotes `"xxx"`, if the value is any other
* object it will be encoded using JSON.stringify() and if there is an exception encoding
* with JSON.stringify() it will return the exception as a string using {@link dumpObj}().
* @since 0.9.0
* @group Conversion
* @group Value
* @param value - The value to be encoded as JSON
* @param format - Identifies whether the JSON value should be formatted when an object
* - `true` - Format with 4 spaces
* - 'number' - The number of spaces to format with
* - `false` (or not Truthy) - Do not format*
* @returns A JSON encoded string representation of the value.
* @example
* ```ts
* // String values
* encodeAsJson("abc.123"); // "\"abc.123\""
* encodeAsJson("321-abc"); // "\"321-abc\""
* encodeAsJson("Hello darkness, my \"old\" friend..."); // "\"Hello darkness, my \\\"old\\\" friend...\""
* encodeAsJson("Hello: Darkness"); // "\"Hello: Darkness\""
* encodeAsJson("Hello\\u003A Darkness"); // "\"Hello\\\\u003A Darkness\""
* encodeAsJson("`!@#$%^&*()_-+=[]{}:;'<>?"); // "\"\\u0060!@#$%^&*()_-+=[]{}:;\\u0027<>?\""
* encodeAsJson("0"); // "\"0\""
* encodeAsJson("1"); // "\"1\""
*
* encodeAsJson([]); // "[]"
* encodeAsJson(["A"]); // "[\"A\"]"
* encodeAsJson([0]); // "[0]"
* encodeAsJson([false]); // "[false]"
* encodeAsJson(new Array(1)); // "[null]"
* encodeAsJson(true); // "true",
* encodeAsJson(false); // "false"
*
* encodeAsJson({}); // "{}"
* encodeAsJson({ Hello: "Darkness" }); // "{\"Hello\":\"Darkness\"}");
* ```
*/
export declare function encodeAsJson(value: T, format?: boolean | number): string;
/**
* Encode a string using URI encoding
* @since 0.13.0
* @group Encoding
* @group Conversion
* @param value - The string value to encode
* @returns The URI encoded string
* @example
* ```ts
* encodeAsUri("Hello World"); // "Hello%20World"
* encodeAsUri("a+b=c"); // "a%2Bb%3Dc"
* ```
*/
export declare function encodeAsUri(value: string): string;
/**
* A type that identifies an enum class generated from a constant enum.
* @group Enum
* @typeParam E - The constant enum type
*
* Returned from {@link createEnum}
*/
export declare type EnumCls = {
readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
} & {
readonly [key in keyof E]: E[key];
};
/**
* A type that identifies an object whose property values are generally mapped to the key of the source type.
* @group Enum
* @typeParam E - The source constant enum type which identifies the keys and values
* @typeParam T - The resulting type with the keys from the source type.
*
* Returned from {@link createEnumKeyMap}
*/
export declare type EnumNameMap = {
readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? key : keyof E;
} & T;
/**
* A type that maps the keys of E to the type of V.
* @group Enum
* @typeParam E - The type of object that defines the Key (typically a constant enum)
* @typeParam V - The value type, typically `string`, `number` but may also be a complex type.
* @typeParam T - The resulting type with the keys from the source type.
*
* Returned from {@link createSimpleMap}
*/
export declare type EnumTypeMap = {
readonly [key in keyof E extends string ? keyof E : never]: V;
} & T;
/**
* A type that identifies an object whose property values are mapped to the resulting values of the source objects keys.
* @group Enum
* @typeParam E - The source type which identifies the keys.
* @typeParam T - The resulting type with the keys from the source type.
*
* Returned from {@link createEnumValueMap}
*/
export declare type EnumValueMap = {
readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : E[key];
} & T;
/**
* The `fnApply` function calls the specified `fn` function with the given `thisArg` as the `this` value,
* and the optional `argArray` arguments provided as an array (or an Array-Like Object).
*
* Normally, when calling a function, the value of `this` inside the function is the object that the
* function was accessed on. With `fnApply()`, you can assign an arbitrary value as this when calling an
* existing function, without first attaching the function to the object as a property. This allows you
* to use methods of one object as generic utility functions.
*
* You can also use any kind of object which is ArrayLike as the second parameter. In practice, this means
* that it needs to have a length property, and integer ("index") properties in the range (0..length - 1).
* For example, you could use a NodeList, or a custom object like `{ 'length': 2, '0': 'eat', '1': 'bananas' }`.
* You can also use `arguments`.
*
* @since 0.9.8
* @group Function
*
* @param fn - The function to be called
* @param thisArg - The value of `this` provided for the call to `fn`. If the function is not in strict mode,
* `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.
* @param argArray - An array-like object, specifying the arguments with which `fn` should be called, or `null` or
* `undefined` if no arguments should be provided to the function.
* @returns The result of calling the function with the specified `this` value and arguments.
* @example
* ```ts
* // min / max number in an array
* let max = fnApply(Math.max, null, [ 21, 42, 84, 168, 7, 3 ]);
* // 168
*
* let min = fnApply(Math.min, null, [ 21, 42, 84, 168, 7, 3 ]);
* // 3
*
* const module1 = {
* prefix: "Hello",
* x: 21,
* getX() {
* return this.x;
* },
* log(value: string) {
* return this.prefix + " " + value + " : " + this.x
* }
* };
*
* // The 'this' parameter of 'getX' is bound to 'module'.
* module1.getX(); // 21
* module1.log("Darkness"); // Hello Darkness : 21
*
* // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
* let module2 = {
* prefix: "my",
* x: 42
* };
*
* // Call the function of module1 with module2 as it's this
* fnApply(module1.getX, module2); // 42
* fnApply(module1.log, module2, [ "friend" ]); // my friend : 42
* ```
*/
export declare function fnApply any, T>(fn: F, thisArg: T, argArray?: ArrayLike): ReturnType;
/**
* Creates a new function that when called will set the value of `thisArg` as the `this` keyword
* value whrn calling the provided `fn` instance, and all of the arguments passed to the new
* function will be passed along to the original provided instance.
* @param fn - The function instance to be called
* @param thisArg - The value to be used as the `this` when calling the `fn`
* @returns The value returned by the original `fn` after executing with the provided `thisArg`.
* @since 0.9.8
* @group Function
* @example
* ```ts
* const module1 = {
* x: 21,
* getX() {
* return this.x;
* },
* };
*
* // The 'this' parameter of 'getX' is bound to 'module'.
* console.log(module1.getX()); // 21
*
* // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
* let module2 = {
* x: 42
* };
*
* module2.getX = fnBind(module1.getX, module2);
* module2.getX(); // 42
*
* // It can also be used to proxy to the original function from the new one
* module2.getX = fnBind(module1.getX, module1);
* module2.getX(); // 21
* ```
*/
export declare function fnBind any, T>(fn: F, thisArg: T): F;
/**
* Creates a new function that when called will set the value of `thisArg` as the `this` keyword
* value whrn calling the provided `fn` instance, and all of the arguments passed to the new
* function will be passed along to the original provided instance.
* @param fn - The function instance to be called
* @param thisArg - The value to be used as the `this` when calling the `fn`
* @returns The value returned by the original `fn` after executing with the provided `thisArg`.
* @since 0.9.8
* @group Function
* @example
* ```ts
* const module1 = {
* x: 21,
* getX() {
* return this.x;
* },
* };
*
* // The 'this' parameter of 'getX' is bound to 'module'.
* console.log(module1.getX()); // 21
*
* // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
* let module2 = {
* x: 42
* };
*
* module2.getX = fnBind(module1.getX, module2);
* module2.getX(); // 42
*
* // It can also be used to proxy to the original function from the new one
* module2.getX = fnBind(module1.getX, module1);
* module2.getX(); // 21
* ```
*/
export declare function fnBind any, T, TArgs extends any[]>(fn: F, thisArg: T, ...argArray: TArgs): BoundFunction;
/**
* Fallback overload for less-specific `Function`-typed call sites where the concrete parameter
* list is not available, such as dynamic proxy wiring.
* @param fn - The function instance to be called.
* @param thisArg - The value to be used as the `this` when calling the `fn`.
* @param argArray - Zero or more arguments to pre-bind to the function.
* @returns The original function type with the bound `this` value and any provided arguments.
* @since 0.9.8
* @group Function
* @example
* ```ts
* const host = {
* prefix: "Hello",
* log(value: string) {
* return this.prefix + " " + value;
* }
* };
*
* const dynamicLog: Function = host.log;
* const bound = fnBind(dynamicLog, host);
*
* bound("friend"); // "Hello friend"
* ```
*/
export declare function fnBind(fn: F, thisArg: T, ...argArray: any[]): F;
/**
* Creates a new bound function using `fn.bind()` where the pre-bound arguments are supplied as an
* array or tuple value, similar to how {@link fnApply} supplies arguments to invocation.
*
* This is useful when the argument list is already available as an array or tuple value,
* but you want to return a reusable bound function rather than invoke immediately.
* @param fn - The function instance to bind.
* @param thisArg - The value to be used as the `this` when calling `fn`.
* @param argArray - Optional array or tuple value containing arguments to pre-bind to `fn`.
* @returns A new bound function.
* @since 0.15.0
* @group Function
* @example
* ```ts
* const module1 = {
* prefix: "Hello",
* log(value: string, punctuation: string) {
* return this.prefix + " " + value + punctuation;
* }
* };
*
* const module2 = {
* prefix: "Hi"
* };
*
* const bound = fnBindArgs(module1.log, module2, ["friend"]);
* bound("!"); // "Hi friend!"
* ```
*/
export declare function fnBindArgs any, T, TArgs extends any[]>(fn: F, thisArg: T, argArray: TArgs): BoundFunction;
export declare function fnBindArgs any, T>(fn: F, thisArg: T): F;
/**
* The `fnCall` function calls the function with the given `thisArg` as the `this` value and with
* al of the `_args` provided as it's `arguments`.
*
* Note: This is almost identical to `fnApply`, except that the function arguments are passed to `fnCall`
* individually as a list, while with `fnApply` that are combined into a single array argument.
*
* Normally, when calling a function, the value of `this` inside the function is the object that the
* function was accessed on. With `fnCall()`, you can pass an arbitrary value as the `this` when calling an
* existing function, without first attaching the function to the object as a property. This allows you
* to use methods of one object as generic utility functions.
*
* @since 0.9.8
* @group Function
*
* @param fn - The function to be called
* @param thisArg - The value of `this` provided for the call to `fn`. If the function is not in strict mode,
* `null` and `undefined` will be replaced with the global object, and primitive values will be converted to objects.
* @param _args - The zero or more arguments to be passed to the `fn` function.
* @returns The result of calling the function with the specified `this` value and arguments.
* @example
* ```ts
* // min / max number in an array
* let max = fnCall(Math.max, null, 21, 42, 84, 168, 7, 3);
* // 168
*
* let min = fnCall(Math.min, null, 21, 42, 84, 168, 7, 3);
* // 3
*
* const module1 = {
* prefix: "Hello",
* x: 21,
* getX() {
* return this.x;
* },
* log(value: string) {
* return this.prefix + " " + value + " : " + this.x
* }
* };
*
* // The 'this' parameter of 'getX' is bound to 'module'.
* module1.getX(); // 21
* module1.log("Darkness"); // Hello Darkness : 21
*
* // Create a new function 'boundGetX' with the 'this' parameter bound to 'module'.
* let module2 = {
* prefix: "my",
* x: 42
* };
*
* // Call the function of module1 with module2 as it's this
* fnCall(module1.getX, module2); // 42
* fnCall(module1.log, module2, "friend"); // my friend : 42
* ```
*/
export declare function fnCall any, T>(fn: F, thisArg: T, ...args: Parameters): ReturnType;
/**
* Calls the provided `callbackFn` once for each own enumerable key (string and symbol) in the
* supplied value. The callback can stop iteration early by returning `-1`.
*
* This helper works with plain objects, arrays, and functions while safely ignoring
* `null` and `undefined` values.
*
* **Note:** Unlike {@link objForEachKey}, this helper also iterates enumerable symbol keys via
* `Object.getOwnPropertySymbols`. Use {@link forEachOwnKeySafe} when iterating untrusted input
* to filter out unsafe keys like `__proto__`, `constructor`, and `prototype`.
* @since 0.14.0
* @group Object
* @typeParam T - The source type.
* @param theObject - The object-like value to iterate.
* @param callbackfn - Invoked for each own enumerable key.
* @param thisArg - [Optional] The `this` context for the callback. If omitted, `null`, or
* `undefined`, the iterated object is used as `this`.
* @example
* ```ts
* // Iterates both string and symbol keys
* const sym = Symbol("id");
* const obj = { name: "Alice", [sym]: 42 };
*
* forEachOwnKey(obj, (key, value) => {
* console.log(String(key), value);
* // "name" "Alice"
* // "Symbol(id)" 42
* });
* ```
* @example
* ```ts
* // Stop iteration early by returning -1
* const obj = { a: 1, b: 2, c: 3 };
* forEachOwnKey(obj, (key) => {
* console.log(key); // "a", "b"
* if (key === "b") {
* return -1; // stops here
* }
* });
* ```
* @example
* ```ts
* // Custom this context
* const obj = { value: 10 };
* const ctx = { multiplier: 3 };
* forEachOwnKey(obj, function(key, val) {
* console.log((val as number) * this.multiplier); // 30
* }, ctx);
* ```
*/
export declare function forEachOwnKey(theObject: T, callbackfn: (key: PropertyKey, value: T[keyof T]) => void | number, thisArg?: any): void;
/**
* Calls the provided `callbackFn` once for each own enumerable key (string and symbol) in the
* supplied value, skipping keys that are considered unsafe (`__proto__`, `constructor`,
* `prototype`). The callback can stop iteration early by returning `-1`.
*
* This helper wraps {@link forEachOwnKey} with extra key filtering for safer assignment flows.
* Use this instead of {@link forEachOwnKey} whenever keys come from untrusted input (e.g.
* user-supplied objects, parsed JSON).
* @since 0.14.0
* @group Object
* @typeParam T - The source type.
* @param theObject - The object-like value to iterate.
* @param callbackfn - Invoked for each safe own enumerable key.
* @param thisArg - [Optional] The `this` context for the callback. If omitted, `null`, or
* `undefined`, the iterated object is used as `this`.
* @example
* ```ts
* // Safely copy properties from an untrusted source
* function safeMerge(target: T, source: any): T {
* forEachOwnKeySafe(source, (key, value) => {
* (target as any)[key] = value;
* });
* return target;
* }
*
* // Note: use Object.defineProperty so "__proto__" is a real own enumerable
* // property rather than being treated as prototype syntax by the JS engine.
* const src: any = { name: "Alice" };
* Object.defineProperty(src, "__proto__", { value: "attack", enumerable: true, configurable: true, writable: true });
* const result = safeMerge({}, src);
* // result.name === "Alice" (__proto__ was silently skipped)
* ```
* @example
* ```ts
* // Symbol keys are included but unsafe string keys are filtered
* const sym = Symbol("safe");
* // Note: use Object.defineProperty so "__proto__" is a real own enumerable
* // property rather than being treated as prototype syntax by the JS engine.
* const obj: any = { a: 1, [sym]: "ok" };
* Object.defineProperty(obj, "__proto__", { value: "bad", enumerable: true, configurable: true, writable: true });
*
* forEachOwnKeySafe(obj, (key, value) => {
* console.log(String(key), value);
* // "a" 1
* // "Symbol(safe)" "ok"
* // "__proto__" is never visited
* });
* ```
* @example
* ```ts
* // Stop iteration early by returning -1
* const obj = { a: 1, b: 2, c: 3 };
* forEachOwnKeySafe(obj, (key) => {
* console.log(key); // "a", "b"
* if (key === "b") {
* return -1; // stops here
* }
* });
* ```
*/
export declare function forEachOwnKeySafe(theObject: T, callbackfn: (key: PropertyKey, value: T[keyof T]) => void | number, thisArg?: any): void;
/**
* Deep copy handler to identify and copy functions. This handler just returns the original
* function so the original function will be assigned to any new deep copied instance.
* @since 0.4.4
* @group Object - Deep Copy
* @param details - The details object for the current property being copied
* @returns `true` if the current value is a function otherwise `false`
*/
export declare function functionDeepCopyHandler(details: IObjDeepCopyHandlerDetails): boolean;
/**
* Returns the global `cancelIdleCallback` function if available, which can be used to
* cancel a previously scheduled idle callback, or if the runtime does not support the
* `cancelIdleCallback` it will return `null`.
*
* @function
* @since 0.11.2
* @group Idle
* @group Environment
*/
export declare const getCancelIdleCallback: () => CancelIdleCallback;
/**
* Create and return a readonly {@link ICachedValue} instance which will cache and return the value returned
* by the callback function. The callback function will only be called once, multiple access of the value
* will not cause re-execution of the callback as the result from the first call is cached internally.
* This version supports passing arguments to the callback function.
* This is a lightweight version of {@link getLazy} which does not support any expiration or invalidation,
* it also will not honor the {@link setBypassLazyCache} setting and will always return the provided value.
* This is the same as {@link createDeferredCachedValue} but allows passing an array of arguments to the
* callback function.
* @since 0.12.3
* @group Helpers
* @group Cache
* @typeParam R - The type of the value to be cached
* @typeParam F - The type of the callback function, defaults to () => T if not specified
* @param cb - The callback function to fetch the value to be lazily evaluated and cached
* @param argArray - Optional array of arguments to be passed to the callback function
* @returns A new readonly {@link ICachedValue} instance which wraps the callback and will be used to cache
* the result of the callback
* @example
* ```ts
* // This does not cause the evaluation to occur
* let cachedValue = getDeferred(() => callSomeExpensiveFunction());
* let theValue;
*
* // With arguments - the argument types are inferred from the callback
* let cachedValueWithArgs = getDeferred(
* (id: number, name: string) => callSomeExpensiveFunction(id, name),
* [123, "test"]
* );
*
* // Just checking if there is an object still does not cause the evaluation
* if (cachedValue) {
* // This will cause the evaluation to occur and the result will be cached
* theValue = cachedValue.v;
* }
*
* // Accessing the value again will not cause the re-evaluation to occur, it will just return the same
* // result value again.
* theValue === cachedValue.v; // true
* ```
*/
export declare function getDeferred R = (...args: any[]) => R>(cb: F | ((...args: Parameters) => R), argArray?: Parameters): ICachedValue;
/**
* Return the global `document` instance.
* @function
* @group Environment
* @returns
*/
export declare const getDocument: () => Document;
/**
* Returns the current global scope object, for a normal web page this will be the current
* window, for a Web Worker this will be current worker global scope via "self". The internal
* implementation returns the first available instance object in the following order
* - globalThis (New standard)
* - self (Will return the current window instance for supported browsers)
* - window (fallback for older browser implementations)
* - global (NodeJS standard)
* - (When all else fails)
* While the return type is a Window for the normal case, not all environments will support all
* of the properties or functions. And this caches the lookup of the global as in some environments
* this can be an expensive operation.
* @group Environment
* @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
* cause the cached global to be reset.
*/
export declare function getGlobal(useCached?: boolean): Window;
/**
* Returns the global `history` instance
* @function
* @group Environment
* @returns
*/
export declare const getHistory: () => History;
/**
* Returns the global `requestIdleCallback` function if available, which can be used to
* schedule work when there is free time in the event loop, or if the runtime does not
* support the `requestIdleCallback` it will return `null`.
*
* @function
* @since 0.11.2
* @group Idle
* @group Environment
*/
export declare const getIdleCallback: () => RequestIdleCallback;
/**
* Return the named global object if available, will return null if the object is not available.
* @group Environment
* @param name - The globally named object, may be any valid property key (string, number or symbol)
* @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
* cause the cached global to be reset.
* @example
* ```ts
* // This does not cause the evaluation to occur
* window.myGlobal = "Hello";
* let cachedValue = getInst("myGlobal");
* // cachedValue === "Hello"
*
* window.myGlobal = "Darkness";
* // getInst("myGlobal") === "Darkness"
*
* let promiseCls = getInst("Promise");
* // May throw if the global is not supported by the runtime
* // otherwise the Promise class.
* ```
*/
export declare function getInst(name: string | number | symbol, useCached?: boolean): T | null;
/**
* Helper to obtain the integer value using base 10 conversion from a string,
* also handles `null`, `undefined` and `Nan` cases which will all return the
* default value.
* @group Conversion
* @group Value
* @param value - The string or numeric value to get the integer value from
* @param defValue - The default value if unsuccessful
* @returns The default or parsed value.
*/
export declare function getIntValue(value?: string | number, defValue?: number): number;
/**
* If Symbols are supported then get the property of the global Symbol, if Symbol's are
* not supported and noPoly is true it returns null. Used to access the well known symbols.
* @group Symbol
* @param name - The property name to return (if it exists) for Symbol
* @param noPoly - Flag indicating whether to return a polyfill if symbols are not supported.
* @returns The value of the property if present
* @example
* ```ts
* // If Symbol is supported in the runtime
* getKnownSymbol("toStringTag") === Symbol.toStringTag; // true
* getKnownSymbol(WellKnownSymbols.toStringTag) === Symbol.toStringTag; // true
* ```
*/
export declare function getKnownSymbol(name: string | WellKnownSymbols, noPoly?: boolean): T;
/**
* Create and return an readonly {@link ILazyValue} instance which will cache and return the value returned
* by the callback function. The callback function will only be called once, multiple access of the value
* does not cause re-execution of the callback as the result from the first call is cached internally.
* @since 0.4.5
* @group Lazy
* @param cb - The callback function to fetch the value to be lazily evaluated and cached
* @param argArray - Optional array of arguments to be passed to the callback function (since 0.12.3)
* @returns A new readonly {@link ILazyValue} instance which wraps the callback and will be used to cache
* the result of the callback
* @example
* ```ts
* // This does not cause the evaluation to occur
* let cachedValue = getLazy(() => callSomeExpensiveFunction());
* let theValue;
*
* // With arguments - the argument types are inferred from the callback
* let cachedValueWithArgs = getLazy(
* (id: number, name: string) => callSomeExpensiveFunction(id, name),
* [123, "test"]
* );
*
* // Just checking if there is an object still does not cause the evaluation
* if (cachedValue) {
* // This will cause the evaluation to occur and the result will be cached
* theValue = cachedValue.v;
* }
*
* // Accessing the value again will not cause the re-evaluation to occur, it will just return the same
* // result value again.
* theValue === cachedValue.v; // true
*
* ```
*/
export declare function getLazy T = (...args: any[]) => T>(cb: F | ((...args: Parameters