es-toolkit 1.17.0-dev.533 → 1.17.0-dev.535
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/_chunk/{initial-crEecP.js → initial-CMlK06.js} +5 -5
- package/dist/_chunk/{randomInt-CF7bZK.js → randomInt-DJFj2K.js} +1 -1
- package/dist/_chunk/{rest-Bzm2XK.js → rest-CXB7TJ.js} +6 -6
- package/dist/array/fill.d.mts +55 -2
- package/dist/array/fill.d.ts +55 -2
- package/dist/array/head.d.mts +14 -3
- package/dist/array/head.d.ts +14 -3
- package/dist/array/index.js +1 -1
- package/dist/array/join.d.mts +3 -7
- package/dist/array/join.d.ts +3 -7
- package/dist/array/join.mjs +1 -1
- package/dist/array/last.d.mts +23 -1
- package/dist/array/last.d.ts +23 -1
- package/dist/array/maxBy.d.mts +13 -1
- package/dist/array/maxBy.d.ts +13 -1
- package/dist/array/minBy.d.mts +13 -1
- package/dist/array/minBy.d.ts +13 -1
- package/dist/array/toFilled.d.mts +59 -2
- package/dist/array/toFilled.d.ts +59 -2
- package/dist/array/zip.d.mts +65 -7
- package/dist/array/zip.d.ts +65 -7
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.d.mts +2 -4
- package/dist/array/zipObject.d.ts +2 -4
- package/dist/array/zipWith.d.mts +39 -6
- package/dist/array/zipWith.d.ts +39 -6
- package/dist/array/zipWith.mjs +2 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/difference.d.mts +22 -0
- package/dist/compat/array/difference.d.ts +22 -0
- package/dist/compat/array/fill.d.mts +55 -2
- package/dist/compat/array/fill.d.ts +55 -2
- package/dist/compat/array/find.mjs +3 -3
- package/dist/compat/array/findIndex.mjs +3 -3
- package/dist/compat/index.js +43 -34
- package/dist/compat/math/max.d.mts +16 -5
- package/dist/compat/math/max.d.ts +16 -5
- package/dist/compat/math/min.d.mts +16 -4
- package/dist/compat/math/min.d.ts +16 -4
- package/dist/compat/object/get.mjs +1 -1
- package/dist/compat/object/has.mjs +3 -2
- package/dist/compat/object/mapKeys.mjs +7 -6
- package/dist/compat/object/mapValues.mjs +7 -6
- package/dist/compat/object/mergeWith.mjs +5 -3
- package/dist/compat/object/set.mjs +5 -1
- package/dist/compat/predicate/isMatch.mjs +2 -2
- package/dist/compat/string/endsWith.d.mts +1 -1
- package/dist/compat/string/endsWith.d.ts +1 -1
- package/dist/compat/string/endsWith.mjs +2 -2
- package/dist/compat/string/repeat.d.mts +1 -1
- package/dist/compat/string/repeat.d.ts +1 -1
- package/dist/compat/string/startsWith.d.mts +1 -1
- package/dist/compat/string/startsWith.d.ts +1 -1
- package/dist/compat/string/startsWith.mjs +2 -2
- package/dist/function/after.d.mts +1 -1
- package/dist/function/after.d.ts +1 -1
- package/dist/function/after.mjs +2 -2
- package/dist/function/before.d.mts +1 -1
- package/dist/function/before.d.ts +1 -1
- package/dist/function/before.mjs +3 -3
- package/dist/function/debounce.d.mts +1 -1
- package/dist/function/debounce.d.ts +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.js +1 -1
- package/dist/function/memoize.d.mts +37 -1
- package/dist/function/memoize.d.ts +37 -1
- package/dist/index.js +3 -3
- package/dist/math/clamp.d.mts +14 -3
- package/dist/math/clamp.d.ts +14 -3
- package/dist/math/index.js +1 -1
- package/dist/math/random.d.mts +13 -2
- package/dist/math/random.d.ts +13 -2
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.d.mts +11 -3
- package/dist/math/randomInt.d.ts +11 -3
- package/dist/math/range.d.mts +25 -0
- package/dist/math/range.d.ts +25 -0
- package/dist/object/invert.d.mts +2 -4
- package/dist/object/invert.d.ts +2 -4
- package/dist/predicate/index.js +1 -1
- package/dist/predicate/isRegExp.d.mts +8 -1
- package/dist/predicate/isRegExp.d.ts +8 -1
- package/dist/predicate/isSymbol.d.mts +15 -0
- package/dist/predicate/isSymbol.d.ts +15 -0
- package/dist/predicate/isSymbol.mjs +1 -1
- package/dist/string/capitalize.d.mts +1 -1
- package/dist/string/capitalize.d.ts +1 -1
- package/dist/string/capitalize.mjs +4 -3
- package/dist/string/escapeRegExp.d.mts +5 -0
- package/dist/string/escapeRegExp.d.ts +5 -0
- package/dist/string/escapeRegExp.mjs +1 -1
- package/dist/string/index.js +21 -20
- package/dist/string/kebabCase.d.mts +1 -1
- package/dist/string/kebabCase.d.ts +1 -1
- package/dist/string/kebabCase.mjs +3 -3
- package/dist/string/lowerCase.d.mts +1 -1
- package/dist/string/lowerCase.d.ts +1 -1
- package/dist/string/lowerCase.mjs +3 -3
- package/dist/string/lowerFirst.d.mts +1 -1
- package/dist/string/lowerFirst.d.ts +1 -1
- package/dist/string/lowerFirst.mjs +2 -2
- package/dist/string/pascalCase.d.mts +1 -1
- package/dist/string/pascalCase.d.ts +1 -1
- package/dist/string/pascalCase.mjs +3 -3
- package/dist/string/snakeCase.d.mts +1 -1
- package/dist/string/snakeCase.d.ts +1 -1
- package/dist/string/snakeCase.mjs +3 -3
- package/dist/string/upperFirst.d.mts +1 -1
- package/dist/string/upperFirst.d.ts +1 -1
- package/dist/string/upperFirst.mjs +2 -2
- package/package.json +2 -1
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the difference between two arrays.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two arrays and returns a new array containing the elements
|
|
5
|
+
* that are present in the first array but not in the second array. It effectively
|
|
6
|
+
* filters out any elements from the first array that also appear in the second array.
|
|
7
|
+
*
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
|
|
10
|
+
* from which elements will be compared and filtered.
|
|
11
|
+
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
|
|
12
|
+
* Each element in this array will be checked against the first array, and if a match is found,
|
|
13
|
+
* that element will be excluded from the result.
|
|
14
|
+
* @returns {T[]} A new array containing the elements that are present in the first array but not
|
|
15
|
+
* in the second array.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const array1 = [1, 2, 3, 4, 5];
|
|
19
|
+
* const array2 = [2, 4];
|
|
20
|
+
* const result = difference(array1, array2);
|
|
21
|
+
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
|
|
22
|
+
*/
|
|
1
23
|
declare function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[];
|
|
2
24
|
|
|
3
25
|
export { difference };
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the difference between two arrays.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two arrays and returns a new array containing the elements
|
|
5
|
+
* that are present in the first array but not in the second array. It effectively
|
|
6
|
+
* filters out any elements from the first array that also appear in the second array.
|
|
7
|
+
*
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
|
|
10
|
+
* from which elements will be compared and filtered.
|
|
11
|
+
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
|
|
12
|
+
* Each element in this array will be checked against the first array, and if a match is found,
|
|
13
|
+
* that element will be excluded from the result.
|
|
14
|
+
* @returns {T[]} A new array containing the elements that are present in the first array but not
|
|
15
|
+
* in the second array.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const array1 = [1, 2, 3, 4, 5];
|
|
19
|
+
* const array2 = [2, 4];
|
|
20
|
+
* const result = difference(array1, array2);
|
|
21
|
+
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
|
|
22
|
+
*/
|
|
1
23
|
declare function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[];
|
|
2
24
|
|
|
3
25
|
export { difference };
|
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills the whole array with a specified value.
|
|
3
|
+
*
|
|
4
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
5
|
+
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
6
|
+
* entire array.
|
|
7
|
+
*
|
|
8
|
+
* @template T, U, S, V
|
|
9
|
+
* @param {Array<T | U>} array - The array to fill.
|
|
10
|
+
* @param {U} value - The value to fill the array with.
|
|
11
|
+
* @returns {Array<T | U>} The array with the filled values.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const array = [1, 2, 3];
|
|
15
|
+
* const result = fill(array, 'a');
|
|
16
|
+
* // => ['a', 'a', 'a']
|
|
17
|
+
*
|
|
18
|
+
* const result = fill(Array(3), 2);
|
|
19
|
+
* // => [2, 2, 2]
|
|
20
|
+
*
|
|
21
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
22
|
+
* // => [4, '*', '*', 10]
|
|
23
|
+
*
|
|
24
|
+
* const result = fill(array, '*', -2, -1);
|
|
25
|
+
* // => [1, '*', 3]
|
|
26
|
+
*/
|
|
27
|
+
declare function fill<T>(array: unknown[], value?: T): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Fills elements of an array with a specified value from the start position to the end.
|
|
30
|
+
*
|
|
31
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
32
|
+
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
33
|
+
* entire array.
|
|
34
|
+
*
|
|
35
|
+
* @template T, U, S, V
|
|
36
|
+
* @param {Array<T | U>} array - The array to fill.
|
|
37
|
+
* @param {U} value - The value to fill the array with.
|
|
38
|
+
* @param {S} [start=0] - The start position. Defaults to 0.
|
|
39
|
+
* @returns {Array<T | U>} The array with the filled values.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const array = [1, 2, 3];
|
|
43
|
+
* const result = fill(array, 'a');
|
|
44
|
+
* // => ['a', 'a', 'a']
|
|
45
|
+
*
|
|
46
|
+
* const result = fill(Array(3), 2);
|
|
47
|
+
* // => [2, 2, 2]
|
|
48
|
+
*
|
|
49
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
50
|
+
* // => [4, '*', '*', 10]
|
|
51
|
+
*
|
|
52
|
+
* const result = fill(array, '*', -2, -1);
|
|
53
|
+
* // => [1, '*', 3]
|
|
54
|
+
*/
|
|
55
|
+
declare function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;
|
|
1
56
|
/**
|
|
2
57
|
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
|
|
3
58
|
*
|
|
@@ -26,8 +81,6 @@
|
|
|
26
81
|
* const result = fill(array, '*', -2, -1);
|
|
27
82
|
* // => [1, '*', 3]
|
|
28
83
|
*/
|
|
29
|
-
declare function fill<T>(array: unknown[], value?: T): T[];
|
|
30
|
-
declare function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;
|
|
31
84
|
declare function fill<T, U, S, V>(array: Array<T | U>, value: U, start: S, end: V): Array<T | U>;
|
|
32
85
|
|
|
33
86
|
export { fill };
|
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills the whole array with a specified value.
|
|
3
|
+
*
|
|
4
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
5
|
+
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
6
|
+
* entire array.
|
|
7
|
+
*
|
|
8
|
+
* @template T, U, S, V
|
|
9
|
+
* @param {Array<T | U>} array - The array to fill.
|
|
10
|
+
* @param {U} value - The value to fill the array with.
|
|
11
|
+
* @returns {Array<T | U>} The array with the filled values.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const array = [1, 2, 3];
|
|
15
|
+
* const result = fill(array, 'a');
|
|
16
|
+
* // => ['a', 'a', 'a']
|
|
17
|
+
*
|
|
18
|
+
* const result = fill(Array(3), 2);
|
|
19
|
+
* // => [2, 2, 2]
|
|
20
|
+
*
|
|
21
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
22
|
+
* // => [4, '*', '*', 10]
|
|
23
|
+
*
|
|
24
|
+
* const result = fill(array, '*', -2, -1);
|
|
25
|
+
* // => [1, '*', 3]
|
|
26
|
+
*/
|
|
27
|
+
declare function fill<T>(array: unknown[], value?: T): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Fills elements of an array with a specified value from the start position to the end.
|
|
30
|
+
*
|
|
31
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
32
|
+
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
33
|
+
* entire array.
|
|
34
|
+
*
|
|
35
|
+
* @template T, U, S, V
|
|
36
|
+
* @param {Array<T | U>} array - The array to fill.
|
|
37
|
+
* @param {U} value - The value to fill the array with.
|
|
38
|
+
* @param {S} [start=0] - The start position. Defaults to 0.
|
|
39
|
+
* @returns {Array<T | U>} The array with the filled values.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const array = [1, 2, 3];
|
|
43
|
+
* const result = fill(array, 'a');
|
|
44
|
+
* // => ['a', 'a', 'a']
|
|
45
|
+
*
|
|
46
|
+
* const result = fill(Array(3), 2);
|
|
47
|
+
* // => [2, 2, 2]
|
|
48
|
+
*
|
|
49
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
50
|
+
* // => [4, '*', '*', 10]
|
|
51
|
+
*
|
|
52
|
+
* const result = fill(array, '*', -2, -1);
|
|
53
|
+
* // => [1, '*', 3]
|
|
54
|
+
*/
|
|
55
|
+
declare function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;
|
|
1
56
|
/**
|
|
2
57
|
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
|
|
3
58
|
*
|
|
@@ -26,8 +81,6 @@
|
|
|
26
81
|
* const result = fill(array, '*', -2, -1);
|
|
27
82
|
* // => [1, '*', 3]
|
|
28
83
|
*/
|
|
29
|
-
declare function fill<T>(array: unknown[], value?: T): T[];
|
|
30
|
-
declare function fill<T, U, S>(array: Array<T | U>, value: U, start: S): Array<T | U>;
|
|
31
84
|
declare function fill<T, U, S, V>(array: Array<T | U>, value: U, start: S, end: V): Array<T | U>;
|
|
32
85
|
|
|
33
86
|
export { fill };
|
|
@@ -8,7 +8,7 @@ function find(source, doesMatch) {
|
|
|
8
8
|
values = Object.values(source);
|
|
9
9
|
}
|
|
10
10
|
switch (typeof doesMatch) {
|
|
11
|
-
case
|
|
11
|
+
case "function": {
|
|
12
12
|
if (!Array.isArray(source)) {
|
|
13
13
|
const entries = Object.entries(source);
|
|
14
14
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -23,7 +23,7 @@ function find(source, doesMatch) {
|
|
|
23
23
|
}
|
|
24
24
|
return values.find(doesMatch);
|
|
25
25
|
}
|
|
26
|
-
case
|
|
26
|
+
case "object": {
|
|
27
27
|
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
28
28
|
const key = doesMatch[0];
|
|
29
29
|
const value = doesMatch[1];
|
|
@@ -33,7 +33,7 @@ function find(source, doesMatch) {
|
|
|
33
33
|
return values.find(matches(doesMatch));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
case
|
|
36
|
+
case "string": {
|
|
37
37
|
return values.find(property(doesMatch));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -4,10 +4,10 @@ import { matchesProperty } from '../predicate/matchesProperty.mjs';
|
|
|
4
4
|
|
|
5
5
|
function findIndex(source, doesMatch) {
|
|
6
6
|
switch (typeof doesMatch) {
|
|
7
|
-
case
|
|
7
|
+
case "function": {
|
|
8
8
|
return source.findIndex(doesMatch);
|
|
9
9
|
}
|
|
10
|
-
case
|
|
10
|
+
case "object": {
|
|
11
11
|
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
12
12
|
const key = doesMatch[0];
|
|
13
13
|
const value = doesMatch[1];
|
|
@@ -17,7 +17,7 @@ function findIndex(source, doesMatch) {
|
|
|
17
17
|
return source.findIndex(matches(doesMatch));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
case
|
|
20
|
+
case "string": {
|
|
21
21
|
return source.findIndex(property(doesMatch));
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dist/compat/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const initial = require('../_chunk/initial-
|
|
5
|
+
const initial = require('../_chunk/initial-CMlK06.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
|
-
const rest$1 = require('../_chunk/rest-
|
|
7
|
+
const rest$1 = require('../_chunk/rest-CXB7TJ.js');
|
|
8
8
|
const math_index = require('../math/index.js');
|
|
9
|
-
const randomInt = require('../_chunk/randomInt-
|
|
9
|
+
const randomInt = require('../_chunk/randomInt-DJFj2K.js');
|
|
10
10
|
const toMerged = require('../_chunk/toMerged-DN1PPP.js');
|
|
11
11
|
const isWeakSet$1 = require('../_chunk/isWeakSet-CogETi.js');
|
|
12
12
|
const isTypedArray$1 = require('../_chunk/isTypedArray-Dsrnb1.js');
|
|
@@ -114,7 +114,7 @@ function get(object, path, defaultValue) {
|
|
|
114
114
|
if (Array.isArray(path)) {
|
|
115
115
|
resolvedPath = path;
|
|
116
116
|
}
|
|
117
|
-
else if (typeof path ===
|
|
117
|
+
else if (typeof path === "string" && isDeepKey(path) && object?.[path] == null) {
|
|
118
118
|
resolvedPath = toPath(path);
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
@@ -192,7 +192,7 @@ function isMatch(target, source) {
|
|
|
192
192
|
return true;
|
|
193
193
|
}
|
|
194
194
|
switch (typeof source) {
|
|
195
|
-
case
|
|
195
|
+
case "object": {
|
|
196
196
|
if (source == null) {
|
|
197
197
|
return true;
|
|
198
198
|
}
|
|
@@ -226,7 +226,7 @@ function isMatch(target, source) {
|
|
|
226
226
|
}
|
|
227
227
|
return true;
|
|
228
228
|
}
|
|
229
|
-
case
|
|
229
|
+
case "function": {
|
|
230
230
|
if (Object.keys(source).length > 0) {
|
|
231
231
|
return isMatch(target, { ...source });
|
|
232
232
|
}
|
|
@@ -294,7 +294,7 @@ function has(object, path) {
|
|
|
294
294
|
if (Array.isArray(path)) {
|
|
295
295
|
resolvedPath = path;
|
|
296
296
|
}
|
|
297
|
-
else if (typeof path ===
|
|
297
|
+
else if (typeof path === "string" && isDeepKey(path) && object?.[path] == null) {
|
|
298
298
|
resolvedPath = toPath(path);
|
|
299
299
|
}
|
|
300
300
|
else {
|
|
@@ -307,7 +307,8 @@ function has(object, path) {
|
|
|
307
307
|
for (let i = 0; i < resolvedPath.length; i++) {
|
|
308
308
|
const key = resolvedPath[i];
|
|
309
309
|
if (current == null || !Object.prototype.hasOwnProperty.call(current, key)) {
|
|
310
|
-
const isSparseIndex = (Array.isArray(current) || isArguments(current)) &&
|
|
310
|
+
const isSparseIndex = (Array.isArray(current) || isArguments(current)) &&
|
|
311
|
+
isIndex(key) && key < current.length;
|
|
311
312
|
if (!isSparseIndex) {
|
|
312
313
|
return false;
|
|
313
314
|
}
|
|
@@ -338,7 +339,7 @@ function find(source, doesMatch) {
|
|
|
338
339
|
values = Object.values(source);
|
|
339
340
|
}
|
|
340
341
|
switch (typeof doesMatch) {
|
|
341
|
-
case
|
|
342
|
+
case "function": {
|
|
342
343
|
if (!Array.isArray(source)) {
|
|
343
344
|
const entries = Object.entries(source);
|
|
344
345
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -353,7 +354,7 @@ function find(source, doesMatch) {
|
|
|
353
354
|
}
|
|
354
355
|
return values.find(doesMatch);
|
|
355
356
|
}
|
|
356
|
-
case
|
|
357
|
+
case "object": {
|
|
357
358
|
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
358
359
|
const key = doesMatch[0];
|
|
359
360
|
const value = doesMatch[1];
|
|
@@ -363,7 +364,7 @@ function find(source, doesMatch) {
|
|
|
363
364
|
return values.find(matches(doesMatch));
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
|
-
case
|
|
367
|
+
case "string": {
|
|
367
368
|
return values.find(property(doesMatch));
|
|
368
369
|
}
|
|
369
370
|
}
|
|
@@ -371,10 +372,10 @@ function find(source, doesMatch) {
|
|
|
371
372
|
|
|
372
373
|
function findIndex(source, doesMatch) {
|
|
373
374
|
switch (typeof doesMatch) {
|
|
374
|
-
case
|
|
375
|
+
case "function": {
|
|
375
376
|
return source.findIndex(doesMatch);
|
|
376
377
|
}
|
|
377
|
-
case
|
|
378
|
+
case "object": {
|
|
378
379
|
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
379
380
|
const key = doesMatch[0];
|
|
380
381
|
const value = doesMatch[1];
|
|
@@ -384,7 +385,7 @@ function findIndex(source, doesMatch) {
|
|
|
384
385
|
return source.findIndex(matches(doesMatch));
|
|
385
386
|
}
|
|
386
387
|
}
|
|
387
|
-
case
|
|
388
|
+
case "string": {
|
|
388
389
|
return source.findIndex(property(doesMatch));
|
|
389
390
|
}
|
|
390
391
|
}
|
|
@@ -558,7 +559,11 @@ function size(target) {
|
|
|
558
559
|
}
|
|
559
560
|
|
|
560
561
|
function set(obj, path, value) {
|
|
561
|
-
const resolvedPath = Array.isArray(path)
|
|
562
|
+
const resolvedPath = Array.isArray(path)
|
|
563
|
+
? path
|
|
564
|
+
: typeof path === "string"
|
|
565
|
+
? toPath(path)
|
|
566
|
+
: [path];
|
|
562
567
|
let current = obj;
|
|
563
568
|
for (let i = 0; i < resolvedPath.length - 1; i++) {
|
|
564
569
|
const key = resolvedPath[i];
|
|
@@ -668,30 +673,32 @@ function identity(x) {
|
|
|
668
673
|
}
|
|
669
674
|
|
|
670
675
|
function mapKeys(object, getNewKey) {
|
|
671
|
-
getNewKey = getNewKey ??
|
|
676
|
+
getNewKey = getNewKey ??
|
|
677
|
+
identity;
|
|
672
678
|
switch (typeof getNewKey) {
|
|
673
|
-
case
|
|
674
|
-
case
|
|
675
|
-
case
|
|
676
|
-
case
|
|
679
|
+
case "string":
|
|
680
|
+
case "symbol":
|
|
681
|
+
case "number":
|
|
682
|
+
case "object": {
|
|
677
683
|
return toMerged.mapKeys(object, property(getNewKey));
|
|
678
684
|
}
|
|
679
|
-
case
|
|
685
|
+
case "function": {
|
|
680
686
|
return toMerged.mapKeys(object, getNewKey);
|
|
681
687
|
}
|
|
682
688
|
}
|
|
683
689
|
}
|
|
684
690
|
|
|
685
691
|
function mapValues(object, getNewValue) {
|
|
686
|
-
getNewValue = getNewValue ??
|
|
692
|
+
getNewValue = getNewValue ??
|
|
693
|
+
identity;
|
|
687
694
|
switch (typeof getNewValue) {
|
|
688
|
-
case
|
|
689
|
-
case
|
|
690
|
-
case
|
|
691
|
-
case
|
|
695
|
+
case "string":
|
|
696
|
+
case "symbol":
|
|
697
|
+
case "number":
|
|
698
|
+
case "object": {
|
|
692
699
|
return toMerged.mapValues(object, property(getNewValue));
|
|
693
700
|
}
|
|
694
|
-
case
|
|
701
|
+
case "function": {
|
|
695
702
|
return toMerged.mapValues(object, getNewValue);
|
|
696
703
|
}
|
|
697
704
|
}
|
|
@@ -740,7 +747,7 @@ function mergeWith(object, ...otherArgs) {
|
|
|
740
747
|
return result;
|
|
741
748
|
}
|
|
742
749
|
function mergeWithDeep(target, source, merge, stack) {
|
|
743
|
-
if (source == null || typeof source !==
|
|
750
|
+
if (source == null || typeof source !== "object") {
|
|
744
751
|
return target;
|
|
745
752
|
}
|
|
746
753
|
if (stack.has(source)) {
|
|
@@ -764,11 +771,13 @@ function mergeWithDeep(target, source, merge, stack) {
|
|
|
764
771
|
if (isArguments(targetValue)) {
|
|
765
772
|
targetValue = { ...targetValue };
|
|
766
773
|
}
|
|
767
|
-
if (typeof Buffer !==
|
|
774
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(sourceValue)) {
|
|
768
775
|
sourceValue = cloneDeep(sourceValue);
|
|
769
776
|
}
|
|
770
777
|
if (Array.isArray(sourceValue)) {
|
|
771
|
-
targetValue = typeof targetValue ===
|
|
778
|
+
targetValue = typeof targetValue === "object"
|
|
779
|
+
? Array.from(targetValue ?? [])
|
|
780
|
+
: [];
|
|
772
781
|
}
|
|
773
782
|
const merged = merge(targetValue, sourceValue, key, target, source, stack);
|
|
774
783
|
if (merged != null) {
|
|
@@ -848,13 +857,13 @@ function isWeakSet(value) {
|
|
|
848
857
|
return isWeakSet$1.isWeakSet(value);
|
|
849
858
|
}
|
|
850
859
|
|
|
851
|
-
|
|
860
|
+
function startsWith(str, target, position = 0) {
|
|
852
861
|
return str.startsWith(target, position);
|
|
853
|
-
}
|
|
862
|
+
}
|
|
854
863
|
|
|
855
|
-
|
|
864
|
+
function endsWith(str, target, position = str.length) {
|
|
856
865
|
return str.endsWith(target, position);
|
|
857
|
-
}
|
|
866
|
+
}
|
|
858
867
|
|
|
859
868
|
function padStart(str, length = 0, chars = ' ') {
|
|
860
869
|
return str.padStart(length, chars);
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Finds the element in an array that has the maximum value.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
6
|
-
* @returns {T | undefined} The element with the maximum value.
|
|
4
|
+
* @param {[T, ...T[]]} items - The array of elements to search.
|
|
5
|
+
* @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
|
|
7
6
|
* @example
|
|
8
7
|
* // Returns 9
|
|
9
|
-
* max([3, 1, 4, 1, 5, 9])
|
|
8
|
+
* max([3, 1, 4, 1, 5, 9]);
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* // Returns 8
|
|
13
|
-
* max([0, -3, 2, 8, 7])
|
|
12
|
+
* max([0, -3, 2, 8, 7]);
|
|
14
13
|
*/
|
|
15
14
|
declare function max<T>(items: readonly [T, ...T[]]): T;
|
|
15
|
+
/**
|
|
16
|
+
* Finds the element in an array that has the maximum value.
|
|
17
|
+
* Returns undefined when no arguments are provided.
|
|
18
|
+
* @returns {undefined}
|
|
19
|
+
*/
|
|
16
20
|
declare function max(): undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Finds the element in an array that has the maximum value.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of elements in the array.
|
|
25
|
+
* @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
|
|
26
|
+
* @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
|
|
27
|
+
*/
|
|
17
28
|
declare function max<T>(items?: readonly T[]): T | undefined;
|
|
18
29
|
|
|
19
30
|
export { max };
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Finds the element in an array that has the maximum value.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
6
|
-
* @returns {T | undefined} The element with the maximum value.
|
|
4
|
+
* @param {[T, ...T[]]} items - The array of elements to search.
|
|
5
|
+
* @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
|
|
7
6
|
* @example
|
|
8
7
|
* // Returns 9
|
|
9
|
-
* max([3, 1, 4, 1, 5, 9])
|
|
8
|
+
* max([3, 1, 4, 1, 5, 9]);
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* // Returns 8
|
|
13
|
-
* max([0, -3, 2, 8, 7])
|
|
12
|
+
* max([0, -3, 2, 8, 7]);
|
|
14
13
|
*/
|
|
15
14
|
declare function max<T>(items: readonly [T, ...T[]]): T;
|
|
15
|
+
/**
|
|
16
|
+
* Finds the element in an array that has the maximum value.
|
|
17
|
+
* Returns undefined when no arguments are provided.
|
|
18
|
+
* @returns {undefined}
|
|
19
|
+
*/
|
|
16
20
|
declare function max(): undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Finds the element in an array that has the maximum value.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of elements in the array.
|
|
25
|
+
* @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
|
|
26
|
+
* @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.
|
|
27
|
+
*/
|
|
17
28
|
declare function max<T>(items?: readonly T[]): T | undefined;
|
|
18
29
|
|
|
19
30
|
export { max };
|
|
@@ -2,18 +2,30 @@
|
|
|
2
2
|
* Finds the element in an array that has the minimum value.
|
|
3
3
|
*
|
|
4
4
|
* @template T - The type of elements in the array.
|
|
5
|
-
* @param {T[]} items The array of elements to search.
|
|
6
|
-
* @returns {T | undefined} The element with the minimum value.
|
|
5
|
+
* @param {[T, ...T[]]} items - The array of elements to search.
|
|
6
|
+
* @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
|
|
7
7
|
* @example
|
|
8
8
|
* // Returns 1
|
|
9
|
-
* min([3, 1, 4, 1, 5, 9])
|
|
9
|
+
* min([3, 1, 4, 1, 5, 9]);
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* // Returns -3
|
|
13
|
-
* min([0, -3, 2, 8, 7])
|
|
13
|
+
* min([0, -3, 2, 8, 7]);
|
|
14
14
|
*/
|
|
15
15
|
declare function min<T>(items: readonly [T, ...T[]]): T;
|
|
16
|
+
/**
|
|
17
|
+
* Finds the element in an array that has the minimum value.
|
|
18
|
+
* Returns undefined when no arguments are provided.
|
|
19
|
+
* @returns {undefined}
|
|
20
|
+
*/
|
|
16
21
|
declare function min(): undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Finds the element in an array that has the minimum value.
|
|
24
|
+
*
|
|
25
|
+
* @template T - The type of elements in the array.
|
|
26
|
+
* @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
|
|
27
|
+
* @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
|
|
28
|
+
*/
|
|
17
29
|
declare function min<T>(items?: readonly T[]): T | undefined;
|
|
18
30
|
|
|
19
31
|
export { min };
|
|
@@ -2,18 +2,30 @@
|
|
|
2
2
|
* Finds the element in an array that has the minimum value.
|
|
3
3
|
*
|
|
4
4
|
* @template T - The type of elements in the array.
|
|
5
|
-
* @param {T[]} items The array of elements to search.
|
|
6
|
-
* @returns {T | undefined} The element with the minimum value.
|
|
5
|
+
* @param {[T, ...T[]]} items - The array of elements to search.
|
|
6
|
+
* @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
|
|
7
7
|
* @example
|
|
8
8
|
* // Returns 1
|
|
9
|
-
* min([3, 1, 4, 1, 5, 9])
|
|
9
|
+
* min([3, 1, 4, 1, 5, 9]);
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* // Returns -3
|
|
13
|
-
* min([0, -3, 2, 8, 7])
|
|
13
|
+
* min([0, -3, 2, 8, 7]);
|
|
14
14
|
*/
|
|
15
15
|
declare function min<T>(items: readonly [T, ...T[]]): T;
|
|
16
|
+
/**
|
|
17
|
+
* Finds the element in an array that has the minimum value.
|
|
18
|
+
* Returns undefined when no arguments are provided.
|
|
19
|
+
* @returns {undefined}
|
|
20
|
+
*/
|
|
16
21
|
declare function min(): undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Finds the element in an array that has the minimum value.
|
|
24
|
+
*
|
|
25
|
+
* @template T - The type of elements in the array.
|
|
26
|
+
* @param {T[]} [items] - The array of elements to search. Defaults to an empty array.
|
|
27
|
+
* @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.
|
|
28
|
+
*/
|
|
17
29
|
declare function min<T>(items?: readonly T[]): T | undefined;
|
|
18
30
|
|
|
19
31
|
export { min };
|
|
@@ -7,7 +7,7 @@ function get(object, path, defaultValue) {
|
|
|
7
7
|
if (Array.isArray(path)) {
|
|
8
8
|
resolvedPath = path;
|
|
9
9
|
}
|
|
10
|
-
else if (typeof path ===
|
|
10
|
+
else if (typeof path === "string" && isDeepKey(path) && object?.[path] == null) {
|
|
11
11
|
resolvedPath = toPath(path);
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
@@ -8,7 +8,7 @@ function has(object, path) {
|
|
|
8
8
|
if (Array.isArray(path)) {
|
|
9
9
|
resolvedPath = path;
|
|
10
10
|
}
|
|
11
|
-
else if (typeof path ===
|
|
11
|
+
else if (typeof path === "string" && isDeepKey(path) && object?.[path] == null) {
|
|
12
12
|
resolvedPath = toPath(path);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
@@ -21,7 +21,8 @@ function has(object, path) {
|
|
|
21
21
|
for (let i = 0; i < resolvedPath.length; i++) {
|
|
22
22
|
const key = resolvedPath[i];
|
|
23
23
|
if (current == null || !Object.prototype.hasOwnProperty.call(current, key)) {
|
|
24
|
-
const isSparseIndex = (Array.isArray(current) || isArguments(current)) &&
|
|
24
|
+
const isSparseIndex = (Array.isArray(current) || isArguments(current)) &&
|
|
25
|
+
isIndex(key) && key < current.length;
|
|
25
26
|
if (!isSparseIndex) {
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
@@ -3,15 +3,16 @@ import { identity } from '../_internal/identity.mjs';
|
|
|
3
3
|
import { property } from './property.mjs';
|
|
4
4
|
|
|
5
5
|
function mapKeys(object, getNewKey) {
|
|
6
|
-
getNewKey = getNewKey ??
|
|
6
|
+
getNewKey = getNewKey ??
|
|
7
|
+
identity;
|
|
7
8
|
switch (typeof getNewKey) {
|
|
8
|
-
case
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
9
|
+
case "string":
|
|
10
|
+
case "symbol":
|
|
11
|
+
case "number":
|
|
12
|
+
case "object": {
|
|
12
13
|
return mapKeys$1(object, property(getNewKey));
|
|
13
14
|
}
|
|
14
|
-
case
|
|
15
|
+
case "function": {
|
|
15
16
|
return mapKeys$1(object, getNewKey);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -3,15 +3,16 @@ import { identity } from '../_internal/identity.mjs';
|
|
|
3
3
|
import { property } from './property.mjs';
|
|
4
4
|
|
|
5
5
|
function mapValues(object, getNewValue) {
|
|
6
|
-
getNewValue = getNewValue ??
|
|
6
|
+
getNewValue = getNewValue ??
|
|
7
|
+
identity;
|
|
7
8
|
switch (typeof getNewValue) {
|
|
8
|
-
case
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
9
|
+
case "string":
|
|
10
|
+
case "symbol":
|
|
11
|
+
case "number":
|
|
12
|
+
case "object": {
|
|
12
13
|
return mapValues$1(object, property(getNewValue));
|
|
13
14
|
}
|
|
14
|
-
case
|
|
15
|
+
case "function": {
|
|
15
16
|
return mapValues$1(object, getNewValue);
|
|
16
17
|
}
|
|
17
18
|
}
|