source: node_modules/es-toolkit/dist/compat/array/union.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 * This function takes multiple arrays and returns a new array containing only the unique values
3 * from all input arrays, preserving the order of their first occurrence.
4 *
5 * @template T - The type of elements in the arrays.
6 * @param {Array<ArrayLike<T> | null | undefined>} arrays - The arrays to inspect.
7 * @returns {T[]} Returns the new array of combined unique values.
8 *
9 * @example
10 * // Returns [2, 1]
11 * union([2], [1, 2]);
12 *
13 * @example
14 * // Returns [2, 1, 3]
15 * union([2], [1, 2], [2, 3]);
16 *
17 * @example
18 * // Returns [1, 3, 2, [5], [4]] (does not deeply flatten nested arrays)
19 * union([1, 3, 2], [1, [5]], [2, [4]]);
20 *
21 * @example
22 * // Returns [0, 2, 1] (ignores non-array values like 3 and { '0': 1 })
23 * union([0], 3, { '0': 1 }, null, [2, 1]);
24 * @example
25 * // Returns [0, 'a', 2, 1] (treats array-like object { 0: 'a', length: 1 } as a valid array)
26 * union([0], { 0: 'a', length: 1 }, [2, 1]);
27 */
28declare function union<T>(...arrays: Array<ArrayLike<T> | null | undefined>): T[];
29
30export { union };
Note: See TracBrowser for help on using the repository browser.