es-toolkit 1.26.1-dev.866 → 1.26.1-dev.867

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.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Creates a duplicate-free version of an array using a transform function for comparison.
3
+ *
4
+ * @template T
5
+ * @param {ArrayLike<T>} array - The array to inspect.
6
+ * @param {(value: T) => unknown} iteratee - The transform function.
7
+ * @returns {T[]} Returns the new duplicate-free array.
8
+ *
9
+ * @example
10
+ * uniqBy([2.1, 1.2, 2.3], Math.floor);
11
+ * // => [2.1, 1.2]
12
+ */
13
+ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown): T[];
14
+ /**
15
+ * Creates a duplicate-free version of an array using a property name for comparison.
16
+ *
17
+ * @template T
18
+ * @param {ArrayLike<T>} array - The array to inspect.
19
+ * @param {string} path - The property path to get values from.
20
+ * @returns {T[]} Returns the new duplicate-free array.
21
+ *
22
+ * @example
23
+ * const users = [
24
+ * { 'user': 'barney', 'age': 36 },
25
+ * { 'user': 'fred', 'age': 40 },
26
+ * { 'user': 'barney', 'age': 37 }
27
+ * ];
28
+ * uniqBy(users, 'user');
29
+ * // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
30
+ */
31
+ declare function uniqBy<T>(array: ArrayLike<T>, path: string): T[];
32
+ /**
33
+ * Creates a duplicate-free version of an array using a property index for comparison.
34
+ *
35
+ * @template T
36
+ * @param {ArrayLike<T>} array - The array to inspect.
37
+ * @param {number} index - The index to get values from.
38
+ * @returns {T[]} Returns the new duplicate-free array.
39
+ *
40
+ * @example
41
+ * const arrays = [[2], [3], [1], [2], [3], [1]];
42
+ * uniqBy(arrays, 0);
43
+ * // => [[2], [3], [1]]
44
+ */
45
+ declare function uniqBy<T>(array: ArrayLike<T>, index: number): T[];
46
+ /**
47
+ * Creates a duplicate-free version of an array, combining multiple arrays and using an optional transform function.
48
+ *
49
+ * @template T
50
+ * @param {ArrayLike<T>} array - The array to inspect.
51
+ * @param {...Array<ArrayLike<T> | ((value: T) => unknown) | string>} values - Additional arrays and/or iteratee.
52
+ * @returns {T[]} Returns the new duplicate-free array.
53
+ *
54
+ * @example
55
+ * uniqBy([1, 2], [2, 3], [3, 4], Math.floor);
56
+ * // => [1, 2, 3, 4]
57
+ */
58
+ declare function uniqBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T> | ((value: T) => unknown) | string>): T[];
59
+
60
+ export { uniqBy };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Creates a duplicate-free version of an array using a transform function for comparison.
3
+ *
4
+ * @template T
5
+ * @param {ArrayLike<T>} array - The array to inspect.
6
+ * @param {(value: T) => unknown} iteratee - The transform function.
7
+ * @returns {T[]} Returns the new duplicate-free array.
8
+ *
9
+ * @example
10
+ * uniqBy([2.1, 1.2, 2.3], Math.floor);
11
+ * // => [2.1, 1.2]
12
+ */
13
+ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown): T[];
14
+ /**
15
+ * Creates a duplicate-free version of an array using a property name for comparison.
16
+ *
17
+ * @template T
18
+ * @param {ArrayLike<T>} array - The array to inspect.
19
+ * @param {string} path - The property path to get values from.
20
+ * @returns {T[]} Returns the new duplicate-free array.
21
+ *
22
+ * @example
23
+ * const users = [
24
+ * { 'user': 'barney', 'age': 36 },
25
+ * { 'user': 'fred', 'age': 40 },
26
+ * { 'user': 'barney', 'age': 37 }
27
+ * ];
28
+ * uniqBy(users, 'user');
29
+ * // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
30
+ */
31
+ declare function uniqBy<T>(array: ArrayLike<T>, path: string): T[];
32
+ /**
33
+ * Creates a duplicate-free version of an array using a property index for comparison.
34
+ *
35
+ * @template T
36
+ * @param {ArrayLike<T>} array - The array to inspect.
37
+ * @param {number} index - The index to get values from.
38
+ * @returns {T[]} Returns the new duplicate-free array.
39
+ *
40
+ * @example
41
+ * const arrays = [[2], [3], [1], [2], [3], [1]];
42
+ * uniqBy(arrays, 0);
43
+ * // => [[2], [3], [1]]
44
+ */
45
+ declare function uniqBy<T>(array: ArrayLike<T>, index: number): T[];
46
+ /**
47
+ * Creates a duplicate-free version of an array, combining multiple arrays and using an optional transform function.
48
+ *
49
+ * @template T
50
+ * @param {ArrayLike<T>} array - The array to inspect.
51
+ * @param {...Array<ArrayLike<T> | ((value: T) => unknown) | string>} values - Additional arrays and/or iteratee.
52
+ * @returns {T[]} Returns the new duplicate-free array.
53
+ *
54
+ * @example
55
+ * uniqBy([1, 2], [2, 3], [3, 4], Math.floor);
56
+ * // => [1, 2, 3, 4]
57
+ */
58
+ declare function uniqBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T> | ((value: T) => unknown) | string>): T[];
59
+
60
+ export { uniqBy };
@@ -0,0 +1,25 @@
1
+ import { flatten } from './flatten.mjs';
2
+ import { last } from './last.mjs';
3
+ import { uniq } from '../../array/uniq.mjs';
4
+ import { uniqBy as uniqBy$1 } from '../../array/uniqBy.mjs';
5
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
6
+ import { iteratee } from '../util/iteratee.mjs';
7
+
8
+ function uniqBy(arr, ...values) {
9
+ if (!isArrayLikeObject(arr)) {
10
+ return [];
11
+ }
12
+ const iteratee$1 = last(values);
13
+ if (iteratee$1 === undefined) {
14
+ return Array.from(arr);
15
+ }
16
+ const validArrays = values.slice(0, -1).filter(isArrayLikeObject);
17
+ const flattenedArrays = flatten(validArrays);
18
+ const allValues = [...Array.from(arr), ...flattenedArrays];
19
+ if (isArrayLikeObject(iteratee$1)) {
20
+ return uniq(allValues);
21
+ }
22
+ return uniqBy$1(allValues, iteratee(iteratee$1));
23
+ }
24
+
25
+ export { uniqBy };
@@ -21,7 +21,6 @@ export { takeWhile } from '../array/takeWhile.mjs';
21
21
  export { toFilled } from '../array/toFilled.mjs';
22
22
  export { unionBy } from '../array/unionBy.mjs';
23
23
  export { unionWith } from '../array/unionWith.mjs';
24
- export { uniqBy } from '../array/uniqBy.mjs';
25
24
  export { uniqWith } from '../array/uniqWith.mjs';
26
25
  export { unzipWith } from '../array/unzipWith.mjs';
27
26
  export { xor } from '../array/xor.mjs';
@@ -114,6 +113,7 @@ export { take } from './array/take.mjs';
114
113
  export { takeRight } from './array/takeRight.mjs';
115
114
  export { union } from './array/union.mjs';
116
115
  export { uniq } from './array/uniq.mjs';
116
+ export { uniqBy } from './array/uniqBy.mjs';
117
117
  export { unzip } from './array/unzip.mjs';
118
118
  export { without } from './array/without.mjs';
119
119
  export { zip } from './array/zip.mjs';
@@ -21,7 +21,6 @@ export { takeWhile } from '../array/takeWhile.js';
21
21
  export { toFilled } from '../array/toFilled.js';
22
22
  export { unionBy } from '../array/unionBy.js';
23
23
  export { unionWith } from '../array/unionWith.js';
24
- export { uniqBy } from '../array/uniqBy.js';
25
24
  export { uniqWith } from '../array/uniqWith.js';
26
25
  export { unzipWith } from '../array/unzipWith.js';
27
26
  export { xor } from '../array/xor.js';
@@ -114,6 +113,7 @@ export { take } from './array/take.js';
114
113
  export { takeRight } from './array/takeRight.js';
115
114
  export { union } from './array/union.js';
116
115
  export { uniq } from './array/uniq.js';
116
+ export { uniqBy } from './array/uniqBy.js';
117
117
  export { unzip } from './array/unzip.js';
118
118
  export { without } from './array/without.js';
119
119
  export { zip } from './array/zip.js';
@@ -1214,6 +1214,23 @@ function uniq(arr) {
1214
1214
  return zipWith.uniq(Array.from(arr));
1215
1215
  }
1216
1216
 
1217
+ function uniqBy(arr, ...values) {
1218
+ if (!isArrayLikeObject(arr)) {
1219
+ return [];
1220
+ }
1221
+ const iteratee$1 = last(values);
1222
+ if (iteratee$1 === undefined) {
1223
+ return Array.from(arr);
1224
+ }
1225
+ const validArrays = values.slice(0, -1).filter(isArrayLikeObject);
1226
+ const flattenedArrays = flatten(validArrays);
1227
+ const allValues = [...Array.from(arr), ...flattenedArrays];
1228
+ if (isArrayLikeObject(iteratee$1)) {
1229
+ return zipWith.uniq(allValues);
1230
+ }
1231
+ return zipWith.uniqBy(allValues, iteratee(iteratee$1));
1232
+ }
1233
+
1217
1234
  function unzip(array) {
1218
1235
  if (!isArrayLikeObject(array) || !array.length) {
1219
1236
  return [];
@@ -2554,7 +2571,6 @@ exports.takeWhile = zipWith.takeWhile;
2554
2571
  exports.toFilled = zipWith.toFilled;
2555
2572
  exports.unionBy = zipWith.unionBy;
2556
2573
  exports.unionWith = zipWith.unionWith;
2557
- exports.uniqBy = zipWith.uniqBy;
2558
2574
  exports.uniqWith = zipWith.uniqWith;
2559
2575
  exports.unzipWith = zipWith.unzipWith;
2560
2576
  exports.xor = zipWith.xor;
@@ -2755,6 +2771,7 @@ exports.trimEnd = trimEnd;
2755
2771
  exports.trimStart = trimStart;
2756
2772
  exports.union = union;
2757
2773
  exports.uniq = uniq;
2774
+ exports.uniqBy = uniqBy;
2758
2775
  exports.uniqueId = uniqueId;
2759
2776
  exports.unset = unset;
2760
2777
  exports.unzip = unzip;
@@ -21,7 +21,6 @@ export { takeWhile } from '../array/takeWhile.mjs';
21
21
  export { toFilled } from '../array/toFilled.mjs';
22
22
  export { unionBy } from '../array/unionBy.mjs';
23
23
  export { unionWith } from '../array/unionWith.mjs';
24
- export { uniqBy } from '../array/uniqBy.mjs';
25
24
  export { uniqWith } from '../array/uniqWith.mjs';
26
25
  export { unzipWith } from '../array/unzipWith.mjs';
27
26
  export { xor } from '../array/xor.mjs';
@@ -116,6 +115,7 @@ export { take } from './array/take.mjs';
116
115
  export { takeRight } from './array/takeRight.mjs';
117
116
  export { union } from './array/union.mjs';
118
117
  export { uniq } from './array/uniq.mjs';
118
+ export { uniqBy } from './array/uniqBy.mjs';
119
119
  export { unzip } from './array/unzip.mjs';
120
120
  export { without } from './array/without.mjs';
121
121
  export { zip } from './array/zip.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.866+5053b7f0",
4
+ "version": "1.26.1-dev.867+6d4fe722",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {