super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
44 lines (43 loc) • 1.17 kB
TypeScript
/**
* Creates a duplicate-free version of an array, using SameValueZero for equality comparisons.
*
* @param array - The array to inspect
* @returns The new duplicate-free array
*
* @example
* ```ts
* uniq([2, 1, 2]);
* // => [2, 1]
* ```
*/
export declare function uniq<T>(array: T[]): T[];
/**
* Creates a duplicate-free version of an array using deep equality comparisons.
*
* @param array - The array to inspect
* @returns The new duplicate-free array
*
* @example
* ```ts
* uniqDeep([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]);
* // => [{ 'x': 1 }, { 'x': 2 }]
* ```
*/
export declare function uniqDeep<T>(array: T[]): T[];
/**
* Creates a duplicate-free version of an array using a custom iteratee function.
*
* @param array - The array to inspect
* @param iteratee - The function invoked per element or property name
* @returns The new duplicate-free array
*
* @example
* ```ts
* uniqBy([2.1, 1.2, 2.3], Math.floor);
* // => [2.1, 1.2]
*
* uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
* ```
*/
export declare function uniqBy<T, K = T>(array: T[], iteratee: ((value: T) => K) | keyof T): T[];