super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
45 lines (44 loc) • 1.25 kB
TypeScript
/**
* Creates an array of unique values, in order, from all given arrays.
*
* @param arrays - The arrays to inspect
* @returns The new array of combined unique values
*
* @example
* ```ts
* union([2], [1, 2]);
* // => [2, 1]
* ```
*/
export declare function union<T>(...arrays: T[][]): T[];
/**
* Creates an array of unique values, in order, from all given arrays
* using deep equality comparison.
*
* @param arrays - The arrays to inspect
* @returns The new array of combined unique values
*
* @example
* ```ts
* unionDeep([{ 'x': 1 }], [{ 'x': 1 }, { 'x': 2 }]);
* // => [{ 'x': 1 }, { 'x': 2 }]
* ```
*/
export declare function unionDeep<T>(...arrays: T[][]): T[];
/**
* Creates an array of unique values, in order, from all given arrays
* using a custom iteratee function.
*
* @param arrays - The arrays to inspect with the last argument being a function or property name
* @returns The new array of combined unique values
*
* @example
* ```ts
* unionBy([2.1], [1.2, 2.3], Math.floor);
* // => [2.1, 1.2]
*
* unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
* ```
*/
export declare function unionBy<T, K = T>(...arrays: [...T[][], ((value: T) => K) | keyof T]): T[];