source: node_modules/es-toolkit/dist/compat/array/difference.d.mts@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[a762898]1/**
2 * Computes the difference between an array and multiple arrays.
3 *
4 * @template T
5 * @param {ArrayLike<T> | undefined | null} arr - The primary array from which to derive the difference. This is the main array
6 * from which elements will be compared and filtered.
7 * @param {Array<ArrayLike<T>>} values - Multiple arrays containing elements to be excluded from the primary array.
8 * These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
9 * If a match is found, that element will be excluded from the result.
10 * @returns {T[]} A new array containing the elements that are present in the primary array but not
11 * in the flattened array.
12 *
13 * @example
14 * const array1 = [1, 2, 3, 4, 5];
15 * const array2 = [2, 4];
16 * const array3 = [5, 6];
17 * const result = difference(array1, array2, array3);
18 * // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
19 *
20 * @example
21 * const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };
22 * const arrayLike2 = { 0: 2, 1: 4, length: 2 };
23 * const result = difference(arrayLike1, arrayLike2);
24 * // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.
25 */
26declare function difference<T>(arr: ArrayLike<T> | undefined | null, ...values: Array<ArrayLike<T>>): T[];
27
28export { difference };
Note: See TracBrowser for help on using the repository browser.