es-toolkit 1.27.0-dev.880 → 1.27.0-dev.882
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/uniqBy.d.mts +34 -13
- package/dist/compat/array/uniqBy.d.ts +34 -13
- package/dist/compat/array/uniqBy.mjs +3 -16
- package/dist/compat/index.js +6 -16
- package/dist/compat/string/trim.mjs +1 -1
- package/dist/compat/string/trimEnd.mjs +1 -1
- package/dist/compat/string/trimStart.mjs +1 -1
- package/dist/compat/util/iteratee.d.mts +1 -1
- package/dist/compat/util/iteratee.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,15 @@
|
|
|
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
|
+
* @returns {T[]} Returns the new duplicate-free array.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* uniqBy([1, 2, 3, 1]);
|
|
10
|
+
* // => [1, 2, 3]
|
|
11
|
+
*/
|
|
12
|
+
declare function uniqBy<T>(array: ArrayLike<T>): T[];
|
|
1
13
|
/**
|
|
2
14
|
* Creates a duplicate-free version of an array using a transform function for comparison.
|
|
3
15
|
*
|
|
@@ -16,7 +28,7 @@ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown)
|
|
|
16
28
|
*
|
|
17
29
|
* @template T
|
|
18
30
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
19
|
-
* @param {
|
|
31
|
+
* @param {PropertyKey} iteratee - The property path to get values from.
|
|
20
32
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
21
33
|
*
|
|
22
34
|
* @example
|
|
@@ -28,33 +40,42 @@ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown)
|
|
|
28
40
|
* uniqBy(users, 'user');
|
|
29
41
|
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
30
42
|
*/
|
|
31
|
-
declare function uniqBy<T>(array: ArrayLike<T>,
|
|
43
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: PropertyKey): T[];
|
|
32
44
|
/**
|
|
33
|
-
* Creates a duplicate-free version of an array using a property
|
|
45
|
+
* Creates a duplicate-free version of an array using a property name for comparison.
|
|
34
46
|
*
|
|
35
47
|
* @template T
|
|
36
48
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
37
|
-
* @param {
|
|
49
|
+
* @param {Partial<T>} iteratee - The partial object to get values from.
|
|
38
50
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
39
51
|
*
|
|
40
52
|
* @example
|
|
41
|
-
* const
|
|
42
|
-
*
|
|
43
|
-
*
|
|
53
|
+
* const users = [
|
|
54
|
+
* { 'user': 'barney', 'age': 36 },
|
|
55
|
+
* { 'user': 'fred', 'age': 40 },
|
|
56
|
+
* { 'user': 'barney', 'age': 37 }
|
|
57
|
+
* ];
|
|
58
|
+
* uniqBy(users, { 'user': 'barney'});
|
|
59
|
+
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
44
60
|
*/
|
|
45
|
-
declare function uniqBy<T>(array: ArrayLike<T>,
|
|
61
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: Partial<T>): T[];
|
|
46
62
|
/**
|
|
47
|
-
* Creates a duplicate-free version of an array
|
|
63
|
+
* Creates a duplicate-free version of an array using a property name for comparison.
|
|
48
64
|
*
|
|
49
65
|
* @template T
|
|
50
66
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
51
|
-
* @param {
|
|
67
|
+
* @param {[keyof T, unknown]} iteratee - The property-value pair to get values from.
|
|
52
68
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
53
69
|
*
|
|
54
70
|
* @example
|
|
55
|
-
*
|
|
56
|
-
*
|
|
71
|
+
* const users = [
|
|
72
|
+
* { 'user': 'barney', 'age': 36 },
|
|
73
|
+
* { 'user': 'fred', 'age': 40 },
|
|
74
|
+
* { 'user': 'barney', 'age': 37 }
|
|
75
|
+
* ];
|
|
76
|
+
* uniqBy(users, ['user', 'barney']);
|
|
77
|
+
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
57
78
|
*/
|
|
58
|
-
declare function uniqBy<T>(array: ArrayLike<T
|
|
79
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: [keyof T, unknown]): T[];
|
|
59
80
|
|
|
60
81
|
export { uniqBy };
|
|
@@ -1,3 +1,15 @@
|
|
|
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
|
+
* @returns {T[]} Returns the new duplicate-free array.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* uniqBy([1, 2, 3, 1]);
|
|
10
|
+
* // => [1, 2, 3]
|
|
11
|
+
*/
|
|
12
|
+
declare function uniqBy<T>(array: ArrayLike<T>): T[];
|
|
1
13
|
/**
|
|
2
14
|
* Creates a duplicate-free version of an array using a transform function for comparison.
|
|
3
15
|
*
|
|
@@ -16,7 +28,7 @@ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown)
|
|
|
16
28
|
*
|
|
17
29
|
* @template T
|
|
18
30
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
19
|
-
* @param {
|
|
31
|
+
* @param {PropertyKey} iteratee - The property path to get values from.
|
|
20
32
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
21
33
|
*
|
|
22
34
|
* @example
|
|
@@ -28,33 +40,42 @@ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown)
|
|
|
28
40
|
* uniqBy(users, 'user');
|
|
29
41
|
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
30
42
|
*/
|
|
31
|
-
declare function uniqBy<T>(array: ArrayLike<T>,
|
|
43
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: PropertyKey): T[];
|
|
32
44
|
/**
|
|
33
|
-
* Creates a duplicate-free version of an array using a property
|
|
45
|
+
* Creates a duplicate-free version of an array using a property name for comparison.
|
|
34
46
|
*
|
|
35
47
|
* @template T
|
|
36
48
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
37
|
-
* @param {
|
|
49
|
+
* @param {Partial<T>} iteratee - The partial object to get values from.
|
|
38
50
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
39
51
|
*
|
|
40
52
|
* @example
|
|
41
|
-
* const
|
|
42
|
-
*
|
|
43
|
-
*
|
|
53
|
+
* const users = [
|
|
54
|
+
* { 'user': 'barney', 'age': 36 },
|
|
55
|
+
* { 'user': 'fred', 'age': 40 },
|
|
56
|
+
* { 'user': 'barney', 'age': 37 }
|
|
57
|
+
* ];
|
|
58
|
+
* uniqBy(users, { 'user': 'barney'});
|
|
59
|
+
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
44
60
|
*/
|
|
45
|
-
declare function uniqBy<T>(array: ArrayLike<T>,
|
|
61
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: Partial<T>): T[];
|
|
46
62
|
/**
|
|
47
|
-
* Creates a duplicate-free version of an array
|
|
63
|
+
* Creates a duplicate-free version of an array using a property name for comparison.
|
|
48
64
|
*
|
|
49
65
|
* @template T
|
|
50
66
|
* @param {ArrayLike<T>} array - The array to inspect.
|
|
51
|
-
* @param {
|
|
67
|
+
* @param {[keyof T, unknown]} iteratee - The property-value pair to get values from.
|
|
52
68
|
* @returns {T[]} Returns the new duplicate-free array.
|
|
53
69
|
*
|
|
54
70
|
* @example
|
|
55
|
-
*
|
|
56
|
-
*
|
|
71
|
+
* const users = [
|
|
72
|
+
* { 'user': 'barney', 'age': 36 },
|
|
73
|
+
* { 'user': 'fred', 'age': 40 },
|
|
74
|
+
* { 'user': 'barney', 'age': 37 }
|
|
75
|
+
* ];
|
|
76
|
+
* uniqBy(users, ['user', 'barney']);
|
|
77
|
+
* // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
|
|
57
78
|
*/
|
|
58
|
-
declare function uniqBy<T>(array: ArrayLike<T
|
|
79
|
+
declare function uniqBy<T>(array: ArrayLike<T>, iteratee: [keyof T, unknown]): T[];
|
|
59
80
|
|
|
60
81
|
export { uniqBy };
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import { flatten } from './flatten.mjs';
|
|
2
|
-
import { last } from './last.mjs';
|
|
3
|
-
import { uniq } from '../../array/uniq.mjs';
|
|
4
1
|
import { uniqBy as uniqBy$1 } from '../../array/uniqBy.mjs';
|
|
5
2
|
import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|
6
3
|
import { iteratee } from '../util/iteratee.mjs';
|
|
7
4
|
|
|
8
|
-
function uniqBy(
|
|
9
|
-
if (!isArrayLikeObject(
|
|
5
|
+
function uniqBy(array, iteratee$1) {
|
|
6
|
+
if (!isArrayLikeObject(array)) {
|
|
10
7
|
return [];
|
|
11
8
|
}
|
|
12
|
-
|
|
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));
|
|
9
|
+
return uniqBy$1(Array.from(array), iteratee(iteratee$1));
|
|
23
10
|
}
|
|
24
11
|
|
|
25
12
|
export { uniqBy };
|
package/dist/compat/index.js
CHANGED
|
@@ -1229,21 +1229,11 @@ function uniq(arr) {
|
|
|
1229
1229
|
return zipWith.uniq(Array.from(arr));
|
|
1230
1230
|
}
|
|
1231
1231
|
|
|
1232
|
-
function uniqBy(
|
|
1233
|
-
if (!isArrayLikeObject(
|
|
1232
|
+
function uniqBy(array, iteratee$1) {
|
|
1233
|
+
if (!isArrayLikeObject(array)) {
|
|
1234
1234
|
return [];
|
|
1235
1235
|
}
|
|
1236
|
-
|
|
1237
|
-
if (iteratee$1 === undefined) {
|
|
1238
|
-
return Array.from(arr);
|
|
1239
|
-
}
|
|
1240
|
-
const validArrays = values.slice(0, -1).filter(isArrayLikeObject);
|
|
1241
|
-
const flattenedArrays = flatten(validArrays);
|
|
1242
|
-
const allValues = [...Array.from(arr), ...flattenedArrays];
|
|
1243
|
-
if (isArrayLikeObject(iteratee$1)) {
|
|
1244
|
-
return zipWith.uniq(allValues);
|
|
1245
|
-
}
|
|
1246
|
-
return zipWith.uniqBy(allValues, iteratee(iteratee$1));
|
|
1236
|
+
return zipWith.uniqBy(Array.from(array), iteratee(iteratee$1));
|
|
1247
1237
|
}
|
|
1248
1238
|
|
|
1249
1239
|
function unzip(array) {
|
|
@@ -2457,7 +2447,7 @@ function trim(str, chars, guard) {
|
|
|
2457
2447
|
}
|
|
2458
2448
|
case 'object': {
|
|
2459
2449
|
if (Array.isArray(chars)) {
|
|
2460
|
-
return upperFirst.trim(str, chars.
|
|
2450
|
+
return upperFirst.trim(str, chars.flatMap(x => x.toString().split('')));
|
|
2461
2451
|
}
|
|
2462
2452
|
else {
|
|
2463
2453
|
return upperFirst.trim(str, chars.toString().split(''));
|
|
@@ -2479,7 +2469,7 @@ function trimEnd(str, chars, guard) {
|
|
|
2479
2469
|
}
|
|
2480
2470
|
case 'object': {
|
|
2481
2471
|
if (Array.isArray(chars)) {
|
|
2482
|
-
return upperFirst.trimEnd(str, chars.
|
|
2472
|
+
return upperFirst.trimEnd(str, chars.flatMap(x => x.toString().split('')));
|
|
2483
2473
|
}
|
|
2484
2474
|
else {
|
|
2485
2475
|
return upperFirst.trimEnd(str, chars.toString().split(''));
|
|
@@ -2501,7 +2491,7 @@ function trimStart(str, chars, guard) {
|
|
|
2501
2491
|
}
|
|
2502
2492
|
case 'object': {
|
|
2503
2493
|
if (Array.isArray(chars)) {
|
|
2504
|
-
return upperFirst.trimStart(str, chars.
|
|
2494
|
+
return upperFirst.trimStart(str, chars.flatMap(x => x.toString().split('')));
|
|
2505
2495
|
}
|
|
2506
2496
|
else {
|
|
2507
2497
|
return upperFirst.trimStart(str, chars.toString().split(''));
|
|
@@ -13,7 +13,7 @@ function trim(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trim$1(str, chars.
|
|
16
|
+
return trim$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trim$1(str, chars.toString().split(''));
|
|
@@ -13,7 +13,7 @@ function trimEnd(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trimEnd$1(str, chars.
|
|
16
|
+
return trimEnd$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trimEnd$1(str, chars.toString().split(''));
|
|
@@ -13,7 +13,7 @@ function trimStart(str, chars, guard) {
|
|
|
13
13
|
}
|
|
14
14
|
case 'object': {
|
|
15
15
|
if (Array.isArray(chars)) {
|
|
16
|
-
return trimStart$1(str, chars.
|
|
16
|
+
return trimStart$1(str, chars.flatMap(x => x.toString().split('')));
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
19
|
return trimStart$1(str, chars.toString().split(''));
|
|
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
|
|
|
39
39
|
* const func = iteratee(['a', 1]);
|
|
40
40
|
* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
|
|
41
41
|
*/
|
|
42
|
-
declare function iteratee(value
|
|
42
|
+
declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
|
|
43
43
|
|
|
44
44
|
export { iteratee };
|
|
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
|
|
|
39
39
|
* const func = iteratee(['a', 1]);
|
|
40
40
|
* [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
|
|
41
41
|
*/
|
|
42
|
-
declare function iteratee(value
|
|
42
|
+
declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
|
|
43
43
|
|
|
44
44
|
export { iteratee };
|
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.27.0-dev.
|
|
4
|
+
"version": "1.27.0-dev.882+64368b8b",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|