import { ObjectLiteral, PrimitiveValue } from "../typings"; /** * Return the difference between left in right * @example getDiff([1, 2, 3], [1, 4, 5]) -> [2, 3] */ export declare const getDiff: (left: T[], right: T[]) => T[]; /** * Return the difference between left in right / right in left * @example getSymmetricDiff([1, 2, 3], [1, 4, 5]) -> [2, 3, 4, 5] */ export declare const getSymmetricDiff: (left: T[], right: T[]) => T[]; /** * Return the union between left & right * @example getUnion([1, 2, 3], [1, 4, 5]) -> [1, 2, 3, 4, 5] */ export declare const getUnion: (left: T[], right: T[]) => T[]; /** * Return the intersection between left & right * @example getUnion([1, 2, 3], [1, 4, 5]) -> [1] */ export declare const getIntersection: (left: T[], right: T[]) => T[]; /** * Checks that all items (right) are in left array * @example hasAll([1, 2, 3], [1, 4, 5]) = false * @example hasAll([1, 2, 3, 4, 5], [1, 4, 5]) = true */ export declare const hasAll: (inArray: T[], items: T[]) => boolean; /** * Return uniques/de-duplicated values in array * @example uniques([1, 2, 3, 4, 5].concat([6, 7, 1, 2, 9])) // = [1, 2, 3, 4, 5, 6, 7, 9] */ export declare const uniques: (arr: T[]) => T[]; /** Return uniques/de-duplicated values in array of objects using the given propPath as unique identifier */ export declare const uniquesByProp: (arr: T[], propPathOrGetter: string | ((value: T) => any)) => T[]; /** Exclude items in array */ export declare const exclude: (arr: T[], excluded: T[]) => T[]; /** Find an item/index from its value using a property path in the array (can be nested using a dot delimited syntax) */ export declare const findBy: (arr: Item[], path: K, value: ValueEqualsTo, index?: ByIndex) => ByIndex extends undefined ? Item : ByIndex extends true ? number : Item; export declare function findRight(arr: Item[], predicate: (item: Item) => item is As): As; export type SortDirection = "asc" | "desc"; export declare const compareBasic: (a: number, b: number) => 1 | -1 | 0; /** Sort an array of objects by a common prop key (or dot-delimited path) in given direction (asc|desc, defaults to asc) */ export declare function sortBy(arr: T[], key: K, dir?: SortDirection): T[]; /** Compare (to sort) 2 objects by a common prop key (or dot-delimited path) in given direction (asc|desc, defaults to asc) */ export declare function sortCompareFn(left: T, right: T, key: K, dir?: SortDirection): number; /** Compare arrays & return true if all members are included (order doesn't matter) */ export declare function isEqualArrays(arr1: PrimitiveValue[], arr2: PrimitiveValue[]): boolean; /** Combine one or more array into the first one while pushing only distinct unique values */ export declare const combineUniqueValues: (arr1?: T[], ...arr2: T[][]) => T[]; /** Combine one or more array of objects into the first one while pushing only distinct unique objects using the given propPath as unique identifier */ export declare const combineUniqueValuesByProps: = any>(arrays: T[][], propPath: string) => T[]; /** Get first item of array */ export declare const first: (value: T[]) => T; /** Get last item of array */ export declare const last: (value: T[]) => T; /** Polyfill Array.flatMap */ export declare function flatMap(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[]; /** Make an array of {count} empty elements */ export declare const makeArrayOf: (count: number) => any[]; /** Split an array in chunk of given size */ export declare const chunk: (arr: T[], size: number) => T[][]; /** Array of picked property */ export declare const pluck: (arr: T[], prop: K) => T[K][]; export declare const prependItem: (array: T[], item: T) => T[]; export declare const appendItem: (array: T[], item: T) => T[]; export declare const updateItem: >(array: T[], idPath: string, update: T) => T[]; export declare const removeValue: (array: T[], item: T) => T[]; export declare const removeValueMutate: (array: T[], item: T) => T[]; export declare const removeItem: (array: T[], idPath: string, value: any) => T[]; export declare const removeItemMutate: (array: T[], idPath: string, value: any) => T[]; export declare const updateAtIndex: (array: T[], index: number, update: T) => T[]; export declare const removeAtIndex: (array: T[], index: number) => T[]; export declare const removeAtIndexMutate: (array: T[], index: number) => T[]; export declare function getPrevItem(array: T[], index: number, loop?: boolean, step?: number): T; export declare function getNextItem(array: T[], index: number, loop?: boolean, step?: number): T; /** * Get the next index based on the current index and step. * * @param currentIndex the current index * @param length the total length or count of items * @param step the number of steps * @param loop whether to circle back once `currentIndex` is at the start/end */ export declare function getNextIndex(currentIndex: number, length: number, loop?: boolean, step?: number): number; /** * Get's the previous index based on the current index. * Mostly used for keyboard navigation. * * @param index - the current index * @param length - the length or total length of items in the array * @param loop - whether we should circle back to the * first/last once `currentIndex` is at the start/end */ export declare function getPrevIndex(index: number, length: number, loop?: boolean, step?: number): number; /** Sort array of object by given prop using a reference order array, sort items not in reference order in lasts positions */ export declare const sortArrayOfObjectByPropFromArray: , K extends (string & {}) | keyof T>(arr: T[], prop: K, orderedProp: T[K][]) => T[]; /** Sort array of object by given prop using a reference order array, sort items not in reference order in lasts positions */ export declare const sortListFromRefArray: (arr: T[], orderedProp: T[]) => T[]; export declare const castAsArray: (value: T | T[]) => T[]; //# sourceMappingURL=array.d.ts.map