diginext-utils
Version:
README.md
23 lines • 636 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.union = union;
/**
* Creates an array of unique values from all given arrays.
*
* @template T - The type of elements in the arrays
* @param arrays - Arrays to combine
* @returns A new array with all unique values from all arrays
*
* @example
* ```ts
* union([1, 2], [2, 3], [3, 4]); // [1, 2, 3, 4]
* union(['a'], ['b'], ['a', 'c']); // ['a', 'b', 'c']
* ```
*/
function union(...arrays) {
if (!arrays || arrays.length === 0) {
return [];
}
return Array.from(new Set(arrays.flat()));
}
//# sourceMappingURL=union.js.map