import { KeysMatching, KeysOfArrays, Obj } from '../typescript'; import { CastedArray, DoubleCastedArray } from './Array.types'; /** * Returns an array of unique values from the provided arrays. * * @param values - The arrays containing the values. * @returns - An array of unique values. * @template T - The type of the values in the arrays. */ export declare function getArrayOfUniqueValues(...values: T[][]): T[]; /** * Returns an array containing only the unique values from the input array. * * @param values - The input array. * @returns - An array containing only the unique values from the input array. * @template T - The type of the values in the array. */ export declare function getUniqueValues(values: T[]): T[]; /** * Creates an array with a given `length` using a parser. * * @param length - The length of the array. * @param parser - The parser for the array items. * @template T - The type of the objects in the array. */ export declare function createArray(length: number, parser: (position: number) => T): T[]; /** * Creates an array with a given `length` and each item indicating its position. * * @param length - The length of the array. * @template T - The length of the array. */ export declare function createCountArray(length: T): number[] & { length: T; }; /** * Sorts an array of objects alphabetically based on a specified key. * * @param array - The array of objects to be sorted. * @param key - The key to sort the objects by. * @param [direction] - The sorting direction. If 'descending' is specified, the objects will be sorted in descending order. If not provided, the objects will be sorted in ascending order. * @returns - The sorted array of objects. * @template T - The type of the objects in the array. */ export declare function sortObjectsAlphabetically(array: T[], key: KeysMatching, direction?: 'descending'): T[]; /** * Sorts an array of objects numerically based on a specified key. * * @param array - The array of objects to be sorted. * @param key - The key to sort the objects by. * @param direction - The sorting direction. If 'descending' is specified, the array will be sorted in descending order. Otherwise, it will be sorted in ascending order. Default is ascending order. * @returns - The sorted array of objects. * @template T - The type of the objects in the array. */ export declare function sortObjectsNumerically(array: T[], key: KeysMatching, direction?: 'descending'): T[]; /** * Sorts an array of `strings` alphabetically, in ascending or descending order. * * @param array - The array of strings to be sorted. * @param direction - The sorting direction. If set to 'descending', the array will be sorted in descending order. Defaults to ascending order. * @returns void */ export declare function sortAlphabetically(array: string[], direction?: 'descending'): void; /** * Sorts an array of `numbers` in ascending or descending order. * * @param array - The array of numbers to be sorted. * @param direction - The sorting direction. If set to 'descending', the array will be sorted in descending order. Defaults to ascending order. * @returns void */ export declare function sortNumerically(array: number[], direction?: 'descending'): void; export declare function sortByLength(array: T[]): T[]; /** * Maps the values of a specific key from an array of objects. * * @param array - The array of objects. * @param key - The key to map the values from. * @returns - An array containing the mapped values. * @template T - The type of the objects in the array. * @template K - The key of the objects to map. */ export declare function mapValue(array: T[], key: K): T[K][]; /** * Filters an array based on a given predicate function. * * @template T - The type of elements in the array. * @param array - The array to be filtered. * @param predicate - The predicate function used to filter the array. * @returns - The filtered array. */ export declare function scrutinize(array: T[], predicate: (item: T, index: number) => boolean): T[]; /** * Executes a callback function for each item in an array of objects, where each object has an array property. * The callback function is called with the item from the nested array, the parent object, the index of the item in the * nested array, and the nested array itself. * * @param arr - The array of objects. * @param key - The key of the array property in the objects. * @param callback - The callback function to execute for each item in the nested array. * @returns * @template T - The type of the objects in the array. * @template K - The key of the array property in the objects. */ export declare function doubleLoop>(arr: T[], key: K, callback: (item: CastedArray, parent: T, index: number, array: T[K]) => void): void; /** * Executes a triple loop over an array of objects and invokes a callback function for each iteration. * * @template T - The type of the objects in the array. * @template K - The keys of the objects in the array. * @template KK - The keys of the nested arrays in the objects. * @param arr - The array of objects to iterate over. * @param kays - The keys to access the nested arrays in the objects. * @param callback - The callback function to invoke for each iteration. * @returns {void} */ export declare function tripleLoop, KK extends KeysOfArrays>>(arr: T[], keys: [K, KK], callback: (item: DoubleCastedArray, parent: CastedArray, grandParent: T, index: number, array: DoubleCastedArray[]) => void): void; /** * Returns a random item of a given array * * @param items - The array of objects to pick from. * @template T - The type of the objects in the array. * @returns - The random element */ export declare function getRandomItem(items: T[]): T; /** * Checks if two arrays are equal by comparing their stringified representations. * * @param array1 - The first array to compare. * @param array2 - The second array to compare. * @returns True if the arrays are equal, false otherwise. */ export declare function arraysAreEqual(array1: any[], array2: any[]): boolean; /** * Inserts an element at a certain position in an array without modifying the original array. * * @param array - The original array. * @param element - The element to insert. * @param position - The position at which to insert the element. * @returns - A new array with the element inserted at the specified position. * @template T - The type of the elements in the array. */ export declare function insertElement(array: T[], element: T, position: number): T[]; /** * Shuffles the elements of an array randomly. * * @template T - The type of elements in the array. * @param {T[]} array - The array to be shuffled. * @returns {T[]} - The shuffled array. */ export declare function shuffle(array: T[]): T[]; /** * Converts a single item or an array of items into an array. * * @template T - The type of the item(s). * @param {T | T[]} item - The item or array of items to be converted into an array. * @returns {T[]} An array containing the item(s). */ export declare function arrayfy(item: T | T[]): T[];