source: node_modules/es-toolkit/dist/array/isSubsetWith.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.5 KB
Line 
1/**
2 * Checks if the `subset` array is entirely contained within the `superset` array based on a custom equality function.
3 *
4 * This function takes two arrays and a custom comparison function. It returns a boolean indicating
5 * whether all elements in the subset array are present in the superset array, as determined by the provided
6 * custom equality function.
7 *
8 * @template T - The type of elements contained in the arrays.
9 * @param {T[]} superset - The array that may contain all elements of the subset.
10 * @param {T[]} subset - The array to check against the superset.
11 * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
12 * @returns {boolean} - Returns `true` if all elements of the subset are present in the superset
13 * according to the custom equality function, otherwise returns `false`.
14 *
15 * @example
16 * ```typescript
17 * const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
18 * const subset = [{ id: 2 }, { id: 1 }];
19 * const areItemsEqual = (a, b) => a.id === b.id;
20 * isSubsetWith(superset, subset, areItemsEqual); // true
21 * ```
22 *
23 * @example
24 * ```typescript
25 * const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
26 * const subset = [{ id: 4 }];
27 * const areItemsEqual = (a, b) => a.id === b.id;
28 * isSubsetWith(superset, subset, areItemsEqual); // false
29 * ```
30 */
31declare function isSubsetWith<T>(superset: readonly T[], subset: readonly T[], areItemsEqual: (x: T, y: T) => boolean): boolean;
32
33export { isSubsetWith };
Note: See TracBrowser for help on using the repository browser.