|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1016 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Computes the symmetric difference between two arrays using a custom equality function.
|
|---|
| 3 | * The symmetric difference is the set of elements which are in either of the arrays,
|
|---|
| 4 | * but not in their intersection.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T - Type of elements in the input arrays.
|
|---|
| 7 | *
|
|---|
| 8 | * @param {T[]} arr1 - The first array.
|
|---|
| 9 | * @param {T[]} arr2 - The second array.
|
|---|
| 10 | * @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
|
|---|
| 11 | * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * // Custom equality function for objects with an 'id' property
|
|---|
| 15 | * const areObjectsEqual = (a, b) => a.id === b.id;
|
|---|
| 16 | * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
|
|---|
| 17 | * // Returns [{ id: 1 }, { id: 3 }]
|
|---|
| 18 | */
|
|---|
| 19 | declare function xorWith<T>(arr1: readonly T[], arr2: readonly T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
|
|---|
| 20 |
|
|---|
| 21 | export { xorWith };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.