source: node_modules/es-toolkit/dist/compat/array/intersectionWith.d.ts@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * Creates an array of unique values that are included in all given arrays, using a comparator function for equality comparisons.
3 *
4 * @template T, U
5 * @param {ArrayLike<T> | null | undefined} array - The array to inspect.
6 * @param {ArrayLike<U>} values - The values to compare.
7 * @param {(a: T, b: T | U) => boolean} comparator - The comparator invoked per element.
8 * @returns {T[]} Returns the new array of intersecting values.
9 *
10 * @example
11 * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
12 * const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
13 * intersectionWith(objects, others, (a, b) => a.x === b.x && a.y === b.y);
14 * // => [{ 'x': 1, 'y': 2 }]
15 */
16declare function intersectionWith<T, U>(array: ArrayLike<T> | null | undefined, values: ArrayLike<U>, comparator: (a: T, b: T | U) => boolean): T[];
17/**
18 * Creates an array of unique values that are included in all given arrays, using a comparator function for equality comparisons.
19 *
20 * @template T, U, V
21 * @param {ArrayLike<T> | null | undefined} array - The array to inspect.
22 * @param {ArrayLike<U>} values1 - The first values to compare.
23 * @param {ArrayLike<V>} values2 - The second values to compare.
24 * @param {(a: T, b: T | U | V) => boolean} comparator - The comparator invoked per element.
25 * @returns {T[]} Returns the new array of intersecting values.
26 *
27 * @example
28 * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
29 * const others1 = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
30 * const others2 = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }];
31 * intersectionWith(objects, others1, others2, (a, b) => a.x === b.x && a.y === b.y);
32 * // => [{ 'x': 1, 'y': 2 }]
33 */
34declare function intersectionWith<T, U, V>(array: ArrayLike<T> | null | undefined, values1: ArrayLike<U>, values2: ArrayLike<V>, comparator: (a: T, b: T | U | V) => boolean): T[];
35/**
36 * Creates an array of unique values that are included in all given arrays, using a comparator function for equality comparisons.
37 *
38 * @template T, U, V, W
39 * @param {ArrayLike<T> | null | undefined} array - The array to inspect.
40 * @param {ArrayLike<U>} values1 - The first values to compare.
41 * @param {ArrayLike<V>} values2 - The second values to compare.
42 * @param {...Array<ArrayLike<W> | (a: T, b: T | U | V | W) => boolean>} values - The other arrays to compare, and the comparator to use.
43 * @returns {T[]} Returns the new array of intersecting values.
44 *
45 * @example
46 * const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
47 * const others1 = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
48 * const others2 = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }];
49 * const others3 = [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }];
50 * intersectionWith(objects, others1, others2, others3, (a, b) => a.x === b.x && a.y === b.y);
51 * // => [{ 'x': 1, 'y': 2 }]
52 */
53declare function intersectionWith<T, U, V, W>(array: ArrayLike<T> | null | undefined, values1: ArrayLike<U>, values2: ArrayLike<V>, ...values: Array<ArrayLike<W> | ((a: T, b: T | U | V | W) => boolean)>): T[];
54/**
55 * Creates an array of unique values that are included in all given arrays.
56 *
57 * @template T
58 * @param {ArrayLike<T> | null} [array] - The array to inspect.
59 * @param {...Array<ArrayLike<T> | (a: T, b: never) => boolean>} values - The values to compare.
60 * @returns {T[]} Returns the new array of intersecting values.
61 *
62 * @example
63 * intersectionWith([2, 1], [2, 3]);
64 * // => [2]
65 */
66declare function intersectionWith<T>(array?: ArrayLike<T> | null, ...values: Array<ArrayLike<T> | ((a: T, b: never) => boolean)>): T[];
67
68export { intersectionWith };
Note: See TracBrowser for help on using the repository browser.