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