A lightweight JavaScript library to create an array of unique values, in order, from multiple input arrays.
- Combines multiple arrays into one array of unique values
- Maintains the order of values as they appear in their source arrays
- Simple and intuitive function
You can install this library using npm:
npm install unique-array-merge
Here's how you can use unique-array-merge in your project:
import uniqueArrayMerge from "unique-array-merge";
const array1 = [1, 2, 3];
const array2 = [3, 4, 5];
const result = uniqueArrayMerge(array1, array2);
console.log(result); // [1, 2, 3, 4, 5]
import uniqueArrayMerge from "unique-array-merge";
const numberArray1: number[] = [1, 2, 3];
const numberArray2: number[] = [3, 4, 5];
const result1 = uniqueArrayMerge(numberArray1, numberArray2);
console.log(result1); // [1, 2, 3, 4, 5]
const stringArray1: string[] = ["a", "b", "c"];
const stringArray2: string[] = ["c", "d", "e"];
const result2 = uniqueArrayMerge(stringArray1, stringArray2);
console.log(result2); // ['a', 'b', 'c', 'd', 'e']
uniqueArrayMerge(...arrays)
...arrays
(Array<T[]>
): The arrays to merge.
Array<T>
: The array of unique values.
const array1 = [1, 2, 3];
const array2 = [3, 4, 5];
const result = uniqueArrayMerge(array1, array2);
console.log(result); // [1, 2, 3, 4, 5]
This project is licensed under the MIT License. See the LICENSE file for details.