es-toolkit 1.26.1-dev.864 → 1.26.1-dev.865
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/union.d.mts +30 -0
- package/dist/compat/array/union.d.ts +30 -0
- package/dist/compat/array/union.mjs +11 -0
- package/dist/compat/index.d.mts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +7 -1
- package/dist/compat/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
*/
|
|
28
|
+
declare function union<T>(...arrays: Array<ArrayLike<T> | null | undefined>): T[];
|
|
29
|
+
|
|
30
|
+
export { union };
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
*/
|
|
28
|
+
declare function union<T>(...arrays: Array<ArrayLike<T> | null | undefined>): T[];
|
|
29
|
+
|
|
30
|
+
export { union };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { flatten } from './flatten.mjs';
|
|
2
|
+
import { uniq } from '../../array/uniq.mjs';
|
|
3
|
+
import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|
4
|
+
|
|
5
|
+
function union(...arrays) {
|
|
6
|
+
const validArrays = arrays.filter(isArrayLikeObject);
|
|
7
|
+
const flattened = flatten(validArrays, 1);
|
|
8
|
+
return uniq(flattened);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { union };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -19,7 +19,6 @@ export { shuffle } from '../array/shuffle.mjs';
|
|
|
19
19
|
export { takeRightWhile } from '../array/takeRightWhile.mjs';
|
|
20
20
|
export { takeWhile } from '../array/takeWhile.mjs';
|
|
21
21
|
export { toFilled } from '../array/toFilled.mjs';
|
|
22
|
-
export { union } from '../array/union.mjs';
|
|
23
22
|
export { unionBy } from '../array/unionBy.mjs';
|
|
24
23
|
export { unionWith } from '../array/unionWith.mjs';
|
|
25
24
|
export { uniqBy } from '../array/uniqBy.mjs';
|
|
@@ -113,6 +112,7 @@ export { sortBy } from './array/sortBy.mjs';
|
|
|
113
112
|
export { tail } from './array/tail.mjs';
|
|
114
113
|
export { take } from './array/take.mjs';
|
|
115
114
|
export { takeRight } from './array/takeRight.mjs';
|
|
115
|
+
export { union } from './array/union.mjs';
|
|
116
116
|
export { uniq } from './array/uniq.mjs';
|
|
117
117
|
export { unzip } from './array/unzip.mjs';
|
|
118
118
|
export { without } from './array/without.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export { shuffle } from '../array/shuffle.js';
|
|
|
19
19
|
export { takeRightWhile } from '../array/takeRightWhile.js';
|
|
20
20
|
export { takeWhile } from '../array/takeWhile.js';
|
|
21
21
|
export { toFilled } from '../array/toFilled.js';
|
|
22
|
-
export { union } from '../array/union.js';
|
|
23
22
|
export { unionBy } from '../array/unionBy.js';
|
|
24
23
|
export { unionWith } from '../array/unionWith.js';
|
|
25
24
|
export { uniqBy } from '../array/uniqBy.js';
|
|
@@ -113,6 +112,7 @@ export { sortBy } from './array/sortBy.js';
|
|
|
113
112
|
export { tail } from './array/tail.js';
|
|
114
113
|
export { take } from './array/take.js';
|
|
115
114
|
export { takeRight } from './array/takeRight.js';
|
|
115
|
+
export { union } from './array/union.js';
|
|
116
116
|
export { uniq } from './array/uniq.js';
|
|
117
117
|
export { unzip } from './array/unzip.js';
|
|
118
118
|
export { without } from './array/without.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1201,6 +1201,12 @@ function takeRight(arr, count = 1, guard) {
|
|
|
1201
1201
|
return zipWith.takeRight(toArray(arr), count);
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
|
+
function union(...arrays) {
|
|
1205
|
+
const validArrays = arrays.filter(isArrayLikeObject);
|
|
1206
|
+
const flattened = flatten(validArrays, 1);
|
|
1207
|
+
return zipWith.uniq(flattened);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1204
1210
|
function uniq(arr) {
|
|
1205
1211
|
if (!isArrayLike(arr)) {
|
|
1206
1212
|
return [];
|
|
@@ -2546,7 +2552,6 @@ exports.shuffle = zipWith.shuffle;
|
|
|
2546
2552
|
exports.takeRightWhile = zipWith.takeRightWhile;
|
|
2547
2553
|
exports.takeWhile = zipWith.takeWhile;
|
|
2548
2554
|
exports.toFilled = zipWith.toFilled;
|
|
2549
|
-
exports.union = zipWith.union;
|
|
2550
2555
|
exports.unionBy = zipWith.unionBy;
|
|
2551
2556
|
exports.unionWith = zipWith.unionWith;
|
|
2552
2557
|
exports.uniqBy = zipWith.uniqBy;
|
|
@@ -2748,6 +2753,7 @@ exports.toString = toString;
|
|
|
2748
2753
|
exports.trim = trim;
|
|
2749
2754
|
exports.trimEnd = trimEnd;
|
|
2750
2755
|
exports.trimStart = trimStart;
|
|
2756
|
+
exports.union = union;
|
|
2751
2757
|
exports.uniq = uniq;
|
|
2752
2758
|
exports.uniqueId = uniqueId;
|
|
2753
2759
|
exports.unset = unset;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -19,7 +19,6 @@ export { shuffle } from '../array/shuffle.mjs';
|
|
|
19
19
|
export { takeRightWhile } from '../array/takeRightWhile.mjs';
|
|
20
20
|
export { takeWhile } from '../array/takeWhile.mjs';
|
|
21
21
|
export { toFilled } from '../array/toFilled.mjs';
|
|
22
|
-
export { union } from '../array/union.mjs';
|
|
23
22
|
export { unionBy } from '../array/unionBy.mjs';
|
|
24
23
|
export { unionWith } from '../array/unionWith.mjs';
|
|
25
24
|
export { uniqBy } from '../array/uniqBy.mjs';
|
|
@@ -115,6 +114,7 @@ export { sortBy } from './array/sortBy.mjs';
|
|
|
115
114
|
export { tail } from './array/tail.mjs';
|
|
116
115
|
export { take } from './array/take.mjs';
|
|
117
116
|
export { takeRight } from './array/takeRight.mjs';
|
|
117
|
+
export { union } from './array/union.mjs';
|
|
118
118
|
export { uniq } from './array/uniq.mjs';
|
|
119
119
|
export { unzip } from './array/unzip.mjs';
|
|
120
120
|
export { without } from './array/without.mjs';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.26.1-dev.
|
|
4
|
+
"version": "1.26.1-dev.865+ab6e7c57",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|