source: node_modules/es-toolkit/dist/array/xorBy.d.ts

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

Added visualizations

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/**
2 * Computes the symmetric difference between two arrays using a custom mapping function.
3 * The symmetric difference is the set of elements which are in either of the arrays,
4 * but not in their intersection, determined by the result of the mapping function.
5 *
6 * @template T - Type of elements in the input arrays.
7 * @template U - Type of the values returned by the mapping function.
8 *
9 * @param {T[]} arr1 - The first array.
10 * @param {T[]} arr2 - The second array.
11 * @param {(item: T) => U} mapper - The function to map array elements to comparison values.
12 * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
13 *
14 * @example
15 * // Custom mapping function for objects with an 'id' property
16 * const idMapper = obj => obj.id;
17 * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
18 * // Returns [{ id: 1 }, { id: 3 }]
19 */
20declare function xorBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
21
22export { xorBy };
Note: See TracBrowser for help on using the repository browser.