es-toolkit 1.50.0-dev.2001 → 1.50.0-dev.2026
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 +3 -3
- package/dist/compat/array/chunk.js +1 -0
- package/dist/compat/array/chunk.mjs +1 -0
- package/dist/compat/array/dropRight.d.mts +2 -3
- package/dist/compat/array/dropRight.d.ts +2 -3
- package/dist/compat/array/dropRight.js +4 -4
- package/dist/compat/array/dropRight.mjs +4 -4
- package/dist/compat/array/every.js +9 -9
- package/dist/compat/array/every.mjs +9 -9
- package/dist/compat/array/fill.js +5 -0
- package/dist/compat/array/fill.mjs +5 -0
- package/dist/compat/array/findIndex.js +3 -19
- package/dist/compat/array/findIndex.mjs +3 -19
- package/dist/compat/array/findLast.js +3 -3
- package/dist/compat/array/findLast.mjs +3 -3
- package/dist/compat/array/flatMap.js +3 -8
- package/dist/compat/array/flatMap.mjs +3 -7
- package/dist/compat/array/flatMapDepth.js +1 -1
- package/dist/compat/array/flatMapDepth.mjs +1 -1
- package/dist/compat/array/includes.js +13 -13
- package/dist/compat/array/includes.mjs +13 -13
- package/dist/compat/array/map.js +3 -3
- package/dist/compat/array/map.mjs +3 -3
- package/dist/compat/array/orderBy.js +1 -2
- package/dist/compat/array/orderBy.mjs +1 -2
- package/dist/compat/array/takeRightWhile.js +2 -2
- package/dist/compat/array/takeRightWhile.mjs +2 -2
- package/dist/compat/array/takeWhile.js +2 -2
- package/dist/compat/array/takeWhile.mjs +2 -2
- package/dist/compat/array/uniqBy.js +2 -2
- package/dist/compat/array/uniqBy.mjs +2 -2
- package/dist/compat/compat.js +1 -1
- package/dist/compat/compat.mjs +1 -1
- package/dist/compat/index.js +1 -1
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/util/toArray.js +5 -1
- package/dist/compat/util/toArray.mjs +5 -1
- package/dist/compat/util/toString.js +4 -1
- package/dist/compat/util/toString.mjs +4 -1
- package/dist/function/retry.js +4 -2
- package/dist/function/retry.mjs +1 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -3
- package/dist/index.mjs +7 -4
- package/dist/object/index.d.mts +4 -1
- package/dist/object/index.d.ts +4 -1
- package/dist/object/index.js +6 -0
- package/dist/object/index.mjs +4 -1
- package/dist/object/toConstantCaseKeys.d.mts +53 -0
- package/dist/object/toConstantCaseKeys.d.ts +53 -0
- package/dist/object/toConstantCaseKeys.js +66 -0
- package/dist/object/toConstantCaseKeys.mjs +66 -0
- package/dist/object/toKebabCaseKeys.d.mts +55 -0
- package/dist/object/toKebabCaseKeys.d.ts +55 -0
- package/dist/object/toKebabCaseKeys.js +66 -0
- package/dist/object/toKebabCaseKeys.mjs +66 -0
- package/dist/object/toPascalCaseKeys.d.mts +56 -0
- package/dist/object/toPascalCaseKeys.d.ts +56 -0
- package/dist/object/toPascalCaseKeys.js +66 -0
- package/dist/object/toPascalCaseKeys.mjs +66 -0
- package/dist/string/index.js +3 -3
- package/dist/string/index.mjs +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fill as fill$1 } from "../../array/fill.mjs";
|
|
2
2
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
3
3
|
import { toInteger } from "../util/toInteger.mjs";
|
|
4
|
+
import { isIterateeCall } from "../_internal/isIterateeCall.mjs";
|
|
4
5
|
import { isString } from "../predicate/isString.mjs";
|
|
5
6
|
//#region src/compat/array/fill.ts
|
|
6
7
|
/**
|
|
@@ -33,6 +34,10 @@ import { isString } from "../predicate/isString.mjs";
|
|
|
33
34
|
function fill(array, value, start = 0, end = array ? array.length : 0) {
|
|
34
35
|
if (!isArrayLike(array)) return [];
|
|
35
36
|
if (isString(array)) return array;
|
|
37
|
+
if (start && typeof start !== "number" && isIterateeCall(array, value, start)) {
|
|
38
|
+
start = 0;
|
|
39
|
+
end = array.length;
|
|
40
|
+
}
|
|
36
41
|
start = toInteger(start);
|
|
37
42
|
end = toInteger(end);
|
|
38
43
|
if (!start) start = 0;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_matches = require("../predicate/matches.js");
|
|
3
|
-
const require_matchesProperty = require("../predicate/matchesProperty.js");
|
|
1
|
+
const require_iteratee = require("../util/iteratee.js");
|
|
4
2
|
const require_toInteger = require("../util/toInteger.js");
|
|
5
3
|
const require_identity = require("../function/identity.js");
|
|
6
4
|
//#region src/compat/array/findIndex.ts
|
|
@@ -24,22 +22,8 @@ function findIndex(arr, doesMatch = require_identity.identity, fromIndex = 0) {
|
|
|
24
22
|
fromIndex = require_toInteger.toInteger(fromIndex);
|
|
25
23
|
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
|
|
26
24
|
const subArray = Array.from(arr).slice(fromIndex);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
case "function":
|
|
30
|
-
index = subArray.findIndex(doesMatch);
|
|
31
|
-
break;
|
|
32
|
-
case "object":
|
|
33
|
-
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
34
|
-
const key = doesMatch[0];
|
|
35
|
-
const value = doesMatch[1];
|
|
36
|
-
index = subArray.findIndex(require_matchesProperty.matchesProperty(key, value));
|
|
37
|
-
} else index = subArray.findIndex(require_matches.matches(doesMatch));
|
|
38
|
-
break;
|
|
39
|
-
case "number":
|
|
40
|
-
case "symbol":
|
|
41
|
-
case "string": index = subArray.findIndex(require_property.property(doesMatch));
|
|
42
|
-
}
|
|
25
|
+
const iteratee$1 = require_iteratee.iteratee(doesMatch);
|
|
26
|
+
const index = subArray.findIndex(iteratee$1);
|
|
43
27
|
return index === -1 ? -1 : index + fromIndex;
|
|
44
28
|
}
|
|
45
29
|
//#endregion
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { matches } from "../predicate/matches.mjs";
|
|
3
|
-
import { matchesProperty } from "../predicate/matchesProperty.mjs";
|
|
1
|
+
import { iteratee } from "../util/iteratee.mjs";
|
|
4
2
|
import { toInteger } from "../util/toInteger.mjs";
|
|
5
3
|
import { identity } from "../function/identity.mjs";
|
|
6
4
|
//#region src/compat/array/findIndex.ts
|
|
@@ -24,22 +22,8 @@ function findIndex(arr, doesMatch = identity, fromIndex = 0) {
|
|
|
24
22
|
fromIndex = toInteger(fromIndex);
|
|
25
23
|
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
|
|
26
24
|
const subArray = Array.from(arr).slice(fromIndex);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
case "function":
|
|
30
|
-
index = subArray.findIndex(doesMatch);
|
|
31
|
-
break;
|
|
32
|
-
case "object":
|
|
33
|
-
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
|
|
34
|
-
const key = doesMatch[0];
|
|
35
|
-
const value = doesMatch[1];
|
|
36
|
-
index = subArray.findIndex(matchesProperty(key, value));
|
|
37
|
-
} else index = subArray.findIndex(matches(doesMatch));
|
|
38
|
-
break;
|
|
39
|
-
case "number":
|
|
40
|
-
case "symbol":
|
|
41
|
-
case "string": index = subArray.findIndex(property(doesMatch));
|
|
42
|
-
}
|
|
25
|
+
const iteratee$1 = iteratee(doesMatch);
|
|
26
|
+
const index = subArray.findIndex(iteratee$1);
|
|
43
27
|
return index === -1 ? -1 : index + fromIndex;
|
|
44
28
|
}
|
|
45
29
|
//#endregion
|
|
@@ -7,7 +7,7 @@ const require_toInteger = require("../util/toInteger.js");
|
|
|
7
7
|
*
|
|
8
8
|
* @template T
|
|
9
9
|
* @param collection - The array or object to search through.
|
|
10
|
-
* @param [
|
|
10
|
+
* @param [_doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
|
|
11
11
|
* @param [fromIndex] - The index to start the search from, defaults to collection.length-1 for arrays or Object.keys(collection).length-1 for objects.
|
|
12
12
|
* @returns The last property value that has the specified property, or `undefined` if no match is found.
|
|
13
13
|
*
|
|
@@ -17,13 +17,13 @@ const require_toInteger = require("../util/toInteger.js");
|
|
|
17
17
|
* const result = findLast(obj, 'name');
|
|
18
18
|
* console.log(result); // { id: 3, name: 'Bob' }
|
|
19
19
|
*/
|
|
20
|
-
function findLast(collection,
|
|
20
|
+
function findLast(collection, _doesMatch = require_identity.identity, fromIndex) {
|
|
21
21
|
if (!collection) return;
|
|
22
22
|
const length = Array.isArray(collection) ? collection.length : Object.keys(collection).length;
|
|
23
23
|
fromIndex = require_toInteger.toInteger(fromIndex ?? length - 1);
|
|
24
24
|
if (fromIndex < 0) fromIndex = Math.max(length + fromIndex, 0);
|
|
25
25
|
else fromIndex = Math.min(fromIndex, length - 1);
|
|
26
|
-
const doesMatch = require_iteratee.iteratee(
|
|
26
|
+
const doesMatch = require_iteratee.iteratee(_doesMatch);
|
|
27
27
|
if (!Array.isArray(collection)) {
|
|
28
28
|
const keys = Object.keys(collection);
|
|
29
29
|
for (let i = fromIndex; i >= 0; i--) {
|
|
@@ -7,7 +7,7 @@ import { toInteger } from "../util/toInteger.mjs";
|
|
|
7
7
|
*
|
|
8
8
|
* @template T
|
|
9
9
|
* @param collection - The array or object to search through.
|
|
10
|
-
* @param [
|
|
10
|
+
* @param [_doesMatch=identity] - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
|
|
11
11
|
* @param [fromIndex] - The index to start the search from, defaults to collection.length-1 for arrays or Object.keys(collection).length-1 for objects.
|
|
12
12
|
* @returns The last property value that has the specified property, or `undefined` if no match is found.
|
|
13
13
|
*
|
|
@@ -17,13 +17,13 @@ import { toInteger } from "../util/toInteger.mjs";
|
|
|
17
17
|
* const result = findLast(obj, 'name');
|
|
18
18
|
* console.log(result); // { id: 3, name: 'Bob' }
|
|
19
19
|
*/
|
|
20
|
-
function findLast(collection,
|
|
20
|
+
function findLast(collection, _doesMatch = identity, fromIndex) {
|
|
21
21
|
if (!collection) return;
|
|
22
22
|
const length = Array.isArray(collection) ? collection.length : Object.keys(collection).length;
|
|
23
23
|
fromIndex = toInteger(fromIndex ?? length - 1);
|
|
24
24
|
if (fromIndex < 0) fromIndex = Math.max(length + fromIndex, 0);
|
|
25
25
|
else fromIndex = Math.min(fromIndex, length - 1);
|
|
26
|
-
const doesMatch = iteratee(
|
|
26
|
+
const doesMatch = iteratee(_doesMatch);
|
|
27
27
|
if (!Array.isArray(collection)) {
|
|
28
28
|
const keys = Object.keys(collection);
|
|
29
29
|
for (let i = fromIndex; i >= 0; i--) {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_isNil = require("../../predicate/isNil.js");
|
|
3
|
-
const require_flattenDepth = require("./flattenDepth.js");
|
|
4
|
-
const require_map = require("./map.js");
|
|
1
|
+
const require_flatMapDepth = require("./flatMapDepth.js");
|
|
5
2
|
//#region src/compat/array/flatMap.ts
|
|
6
3
|
/**
|
|
7
4
|
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
|
|
@@ -15,10 +12,8 @@ const require_map = require("./map.js");
|
|
|
15
12
|
* flatMap([1, 2], n => [n, n * 2]);
|
|
16
13
|
* // => [1, 2, 2, 4]
|
|
17
14
|
*/
|
|
18
|
-
function flatMap(collection, iteratee
|
|
19
|
-
|
|
20
|
-
const mapped = require_isNil.isNil(iteratee) ? require_map.map(collection) : require_map.map(collection, iteratee);
|
|
21
|
-
return require_flattenDepth.flattenDepth(mapped, 1);
|
|
15
|
+
function flatMap(collection, iteratee) {
|
|
16
|
+
return require_flatMapDepth.flatMapDepth(collection, iteratee, 1);
|
|
22
17
|
}
|
|
23
18
|
//#endregion
|
|
24
19
|
exports.flatMap = flatMap;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isNil } from "../../predicate/isNil.mjs";
|
|
3
|
-
import { flattenDepth } from "./flattenDepth.mjs";
|
|
4
|
-
import { map } from "./map.mjs";
|
|
1
|
+
import { flatMapDepth } from "./flatMapDepth.mjs";
|
|
5
2
|
//#region src/compat/array/flatMap.ts
|
|
6
3
|
/**
|
|
7
4
|
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
|
|
@@ -15,9 +12,8 @@ import { map } from "./map.mjs";
|
|
|
15
12
|
* flatMap([1, 2], n => [n, n * 2]);
|
|
16
13
|
* // => [1, 2, 2, 4]
|
|
17
14
|
*/
|
|
18
|
-
function flatMap(collection, iteratee
|
|
19
|
-
|
|
20
|
-
return flattenDepth(isNil(iteratee) ? map(collection) : map(collection, iteratee), 1);
|
|
15
|
+
function flatMap(collection, iteratee) {
|
|
16
|
+
return flatMapDepth(collection, iteratee, 1);
|
|
21
17
|
}
|
|
22
18
|
//#endregion
|
|
23
19
|
export { flatMap };
|
|
@@ -8,7 +8,7 @@ const require_map = require("./map.js");
|
|
|
8
8
|
*
|
|
9
9
|
* @template T, R
|
|
10
10
|
* @param collection - The array or object to iterate over.
|
|
11
|
-
* @param [iteratee] - The function that produces the new array elements.
|
|
11
|
+
* @param [iteratee=identity] - The function that produces the new array elements.
|
|
12
12
|
* @param [depth=1] - The maximum recursion depth.
|
|
13
13
|
* @returns A new array that has been flattened up to the specified depth.
|
|
14
14
|
*
|
|
@@ -8,7 +8,7 @@ import { map } from "./map.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* @template T, R
|
|
10
10
|
* @param collection - The array or object to iterate over.
|
|
11
|
-
* @param [iteratee] - The function that produces the new array elements.
|
|
11
|
+
* @param [iteratee=identity] - The function that produces the new array elements.
|
|
12
12
|
* @param [depth=1] - The maximum recursion depth.
|
|
13
13
|
* @returns A new array that has been flattened up to the specified depth.
|
|
14
14
|
*
|
|
@@ -8,7 +8,7 @@ const require_isString = require("../predicate/isString.js");
|
|
|
8
8
|
*
|
|
9
9
|
* The comparison uses SameValueZero to check for inclusion.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param collection - The source to search in. It can be an array, an object, or a string.
|
|
12
12
|
* @param [target] - The value to search for in the source.
|
|
13
13
|
* @param [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the source.
|
|
14
14
|
* @returns `true` if the value is found in the source, `false` otherwise.
|
|
@@ -19,25 +19,25 @@ const require_isString = require("../predicate/isString.js");
|
|
|
19
19
|
* includes('hello world', 'world'); // true
|
|
20
20
|
* includes('hello world', 'test'); // false
|
|
21
21
|
*/
|
|
22
|
-
function includes(
|
|
23
|
-
if (
|
|
22
|
+
function includes(collection, target, fromIndex, guard) {
|
|
23
|
+
if (collection == null) return false;
|
|
24
24
|
if (guard || !fromIndex) fromIndex = 0;
|
|
25
25
|
else fromIndex = require_toInteger.toInteger(fromIndex);
|
|
26
|
-
if (require_isString.isString(
|
|
27
|
-
if (fromIndex >
|
|
28
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
29
|
-
return
|
|
26
|
+
if (require_isString.isString(collection)) {
|
|
27
|
+
if (fromIndex > collection.length || target instanceof RegExp) return false;
|
|
28
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
29
|
+
return collection.includes(target, fromIndex);
|
|
30
30
|
}
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
if (require_isArrayLike.isArrayLike(
|
|
33
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
34
|
-
for (let i = fromIndex; i <
|
|
31
|
+
if (Array.isArray(collection)) return collection.includes(target, fromIndex);
|
|
32
|
+
if (require_isArrayLike.isArrayLike(collection)) {
|
|
33
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
34
|
+
for (let i = fromIndex; i < collection.length; i++) if (require_eq.eq(collection[i], target)) return true;
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
const keys = Object.keys(
|
|
37
|
+
const keys = Object.keys(collection);
|
|
38
38
|
if (fromIndex < 0) fromIndex = Math.max(0, keys.length + fromIndex);
|
|
39
39
|
for (let i = fromIndex; i < keys.length; i++) {
|
|
40
|
-
const value = Reflect.get(
|
|
40
|
+
const value = Reflect.get(collection, keys[i]);
|
|
41
41
|
if (require_eq.eq(value, target)) return true;
|
|
42
42
|
}
|
|
43
43
|
return false;
|
|
@@ -8,7 +8,7 @@ import { isString } from "../predicate/isString.mjs";
|
|
|
8
8
|
*
|
|
9
9
|
* The comparison uses SameValueZero to check for inclusion.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param collection - The source to search in. It can be an array, an object, or a string.
|
|
12
12
|
* @param [target] - The value to search for in the source.
|
|
13
13
|
* @param [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the source.
|
|
14
14
|
* @returns `true` if the value is found in the source, `false` otherwise.
|
|
@@ -19,24 +19,24 @@ import { isString } from "../predicate/isString.mjs";
|
|
|
19
19
|
* includes('hello world', 'world'); // true
|
|
20
20
|
* includes('hello world', 'test'); // false
|
|
21
21
|
*/
|
|
22
|
-
function includes(
|
|
23
|
-
if (
|
|
22
|
+
function includes(collection, target, fromIndex, guard) {
|
|
23
|
+
if (collection == null) return false;
|
|
24
24
|
if (guard || !fromIndex) fromIndex = 0;
|
|
25
25
|
else fromIndex = toInteger(fromIndex);
|
|
26
|
-
if (isString(
|
|
27
|
-
if (fromIndex >
|
|
28
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
29
|
-
return
|
|
26
|
+
if (isString(collection)) {
|
|
27
|
+
if (fromIndex > collection.length || target instanceof RegExp) return false;
|
|
28
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
29
|
+
return collection.includes(target, fromIndex);
|
|
30
30
|
}
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
if (isArrayLike(
|
|
33
|
-
if (fromIndex < 0) fromIndex = Math.max(0,
|
|
34
|
-
for (let i = fromIndex; i <
|
|
31
|
+
if (Array.isArray(collection)) return collection.includes(target, fromIndex);
|
|
32
|
+
if (isArrayLike(collection)) {
|
|
33
|
+
if (fromIndex < 0) fromIndex = Math.max(0, collection.length + fromIndex);
|
|
34
|
+
for (let i = fromIndex; i < collection.length; i++) if (eq(collection[i], target)) return true;
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
const keys = Object.keys(
|
|
37
|
+
const keys = Object.keys(collection);
|
|
38
38
|
if (fromIndex < 0) fromIndex = Math.max(0, keys.length + fromIndex);
|
|
39
|
-
for (let i = fromIndex; i < keys.length; i++) if (eq(Reflect.get(
|
|
39
|
+
for (let i = fromIndex; i < keys.length; i++) if (eq(Reflect.get(collection, keys[i]), target)) return true;
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
package/dist/compat/array/map.js
CHANGED
|
@@ -3,10 +3,10 @@ const require_range = require("../../math/range.js");
|
|
|
3
3
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
4
4
|
const require_iteratee = require("../util/iteratee.js");
|
|
5
5
|
//#region src/compat/array/map.ts
|
|
6
|
-
function map(collection, _iteratee) {
|
|
6
|
+
function map(collection, _iteratee = require_identity.identity) {
|
|
7
7
|
if (!collection) return [];
|
|
8
|
-
const keys = require_isArrayLike.isArrayLike(collection)
|
|
9
|
-
const iteratee$1 = require_iteratee.iteratee(_iteratee
|
|
8
|
+
const keys = require_isArrayLike.isArrayLike(collection) ? require_range.range(0, collection.length) : Object.keys(collection);
|
|
9
|
+
const iteratee$1 = require_iteratee.iteratee(_iteratee);
|
|
10
10
|
const result = new Array(keys.length);
|
|
11
11
|
for (let i = 0; i < keys.length; i++) {
|
|
12
12
|
const key = keys[i];
|
|
@@ -3,10 +3,10 @@ import { range } from "../../math/range.mjs";
|
|
|
3
3
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
4
4
|
import { iteratee } from "../util/iteratee.mjs";
|
|
5
5
|
//#region src/compat/array/map.ts
|
|
6
|
-
function map(collection, _iteratee) {
|
|
6
|
+
function map(collection, _iteratee = identity) {
|
|
7
7
|
if (!collection) return [];
|
|
8
|
-
const keys = isArrayLike(collection)
|
|
9
|
-
const iteratee$1 = iteratee(_iteratee
|
|
8
|
+
const keys = isArrayLike(collection) ? range(0, collection.length) : Object.keys(collection);
|
|
9
|
+
const iteratee$1 = iteratee(_iteratee);
|
|
10
10
|
const result = new Array(keys.length);
|
|
11
11
|
for (let i = 0; i < keys.length; i++) {
|
|
12
12
|
const key = keys[i];
|
|
@@ -54,8 +54,7 @@ function orderBy(collection, criteria, orders, guard) {
|
|
|
54
54
|
}
|
|
55
55
|
if (typeof criterion === "function") return criterion(object);
|
|
56
56
|
if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
|
|
57
|
-
|
|
58
|
-
return object;
|
|
57
|
+
return object[criterion];
|
|
59
58
|
};
|
|
60
59
|
const preparedCriteria = criteria.map((criterion) => {
|
|
61
60
|
if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
|
|
@@ -54,8 +54,7 @@ function orderBy(collection, criteria, orders, guard) {
|
|
|
54
54
|
}
|
|
55
55
|
if (typeof criterion === "function") return criterion(object);
|
|
56
56
|
if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
|
|
57
|
-
|
|
58
|
-
return object;
|
|
57
|
+
return object[criterion];
|
|
59
58
|
};
|
|
60
59
|
const preparedCriteria = criteria.map((criterion) => {
|
|
61
60
|
if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_identity = require("../../function/identity.js");
|
|
2
2
|
const require_negate = require("../../function/negate.js");
|
|
3
3
|
const require_toArray = require("../_internal/toArray.js");
|
|
4
|
+
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
4
5
|
const require_iteratee = require("../util/iteratee.js");
|
|
5
|
-
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
6
6
|
//#region src/compat/array/takeRightWhile.ts
|
|
7
7
|
/**
|
|
8
8
|
* Creates a slice of the array with elements taken from the end while the specified predicate is satisfied.
|
|
@@ -50,7 +50,7 @@ const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
|
50
50
|
* console.log(result6); // []
|
|
51
51
|
*/
|
|
52
52
|
function takeRightWhile(_array, predicate) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!require_isArrayLike.isArrayLike(_array)) return [];
|
|
54
54
|
const array = require_toArray.toArray(_array);
|
|
55
55
|
const index = array.findLastIndex(require_negate.negate(require_iteratee.iteratee(predicate ?? require_identity.identity)));
|
|
56
56
|
return array.slice(index + 1);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { identity } from "../../function/identity.mjs";
|
|
2
2
|
import { negate } from "../../function/negate.mjs";
|
|
3
3
|
import { toArray } from "../_internal/toArray.mjs";
|
|
4
|
+
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
4
5
|
import { iteratee } from "../util/iteratee.mjs";
|
|
5
|
-
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
6
6
|
//#region src/compat/array/takeRightWhile.ts
|
|
7
7
|
/**
|
|
8
8
|
* Creates a slice of the array with elements taken from the end while the specified predicate is satisfied.
|
|
@@ -50,7 +50,7 @@ import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
|
50
50
|
* console.log(result6); // []
|
|
51
51
|
*/
|
|
52
52
|
function takeRightWhile(_array, predicate) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!isArrayLike(_array)) return [];
|
|
54
54
|
const array = toArray(_array);
|
|
55
55
|
const index = array.findLastIndex(negate(iteratee(predicate ?? identity)));
|
|
56
56
|
return array.slice(index + 1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_toArray = require("../_internal/toArray.js");
|
|
2
|
+
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
2
3
|
const require_iteratee = require("../util/iteratee.js");
|
|
3
|
-
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
4
4
|
const require_identity = require("../function/identity.js");
|
|
5
5
|
const require_negate = require("../function/negate.js");
|
|
6
6
|
//#region src/compat/array/takeWhile.ts
|
|
@@ -50,7 +50,7 @@ const require_negate = require("../function/negate.js");
|
|
|
50
50
|
* console.log(result6); // []
|
|
51
51
|
**/
|
|
52
52
|
function takeWhile(array, predicate) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!require_isArrayLike.isArrayLike(array)) return [];
|
|
54
54
|
const _array = require_toArray.toArray(array);
|
|
55
55
|
const index = _array.findIndex(require_negate.negate(require_iteratee.iteratee(predicate ?? require_identity.identity)));
|
|
56
56
|
return index === -1 ? _array : _array.slice(0, index);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toArray } from "../_internal/toArray.mjs";
|
|
2
|
+
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
2
3
|
import { iteratee } from "../util/iteratee.mjs";
|
|
3
|
-
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
4
4
|
import { identity } from "../function/identity.mjs";
|
|
5
5
|
import { negate } from "../function/negate.mjs";
|
|
6
6
|
//#region src/compat/array/takeWhile.ts
|
|
@@ -50,7 +50,7 @@ import { negate } from "../function/negate.mjs";
|
|
|
50
50
|
* console.log(result6); // []
|
|
51
51
|
**/
|
|
52
52
|
function takeWhile(array, predicate) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!isArrayLike(array)) return [];
|
|
54
54
|
const _array = toArray(array);
|
|
55
55
|
const index = _array.findIndex(negate(iteratee(predicate ?? identity)));
|
|
56
56
|
return index === -1 ? _array : _array.slice(0, index);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_uniqBy = require("../../array/uniqBy.js");
|
|
2
2
|
const require_ary = require("../../function/ary.js");
|
|
3
3
|
const require_identity = require("../../function/identity.js");
|
|
4
|
+
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
4
5
|
const require_iteratee = require("../util/iteratee.js");
|
|
5
|
-
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
|
|
6
6
|
//#region src/compat/array/uniqBy.ts
|
|
7
7
|
function uniqBy(array, iteratee$1 = require_identity.identity) {
|
|
8
|
-
if (!
|
|
8
|
+
if (!require_isArrayLike.isArrayLike(array)) return [];
|
|
9
9
|
return require_uniqBy.uniqBy(Array.from(array), require_ary.ary(require_iteratee.iteratee(iteratee$1), 1));
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { uniqBy as uniqBy$1 } from "../../array/uniqBy.mjs";
|
|
2
2
|
import { ary } from "../../function/ary.mjs";
|
|
3
3
|
import { identity } from "../../function/identity.mjs";
|
|
4
|
+
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
4
5
|
import { iteratee } from "../util/iteratee.mjs";
|
|
5
|
-
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
|
|
6
6
|
//#region src/compat/array/uniqBy.ts
|
|
7
7
|
function uniqBy(array, iteratee$1 = identity) {
|
|
8
|
-
if (!
|
|
8
|
+
if (!isArrayLike(array)) return [];
|
|
9
9
|
return uniqBy$1(Array.from(array), ary(iteratee(iteratee$1), 1));
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
package/dist/compat/compat.js
CHANGED
|
@@ -54,8 +54,8 @@ const require_head = require("./array/head.js");
|
|
|
54
54
|
require("./array/first.js");
|
|
55
55
|
const require_flattenDepth = require("./array/flattenDepth.js");
|
|
56
56
|
const require_map = require("./array/map.js");
|
|
57
|
-
const require_flatMap = require("./array/flatMap.js");
|
|
58
57
|
const require_flatMapDepth = require("./array/flatMapDepth.js");
|
|
58
|
+
const require_flatMap = require("./array/flatMap.js");
|
|
59
59
|
const require_flatMapDeep = require("./array/flatMapDeep.js");
|
|
60
60
|
const require_flatten = require("./array/flatten.js");
|
|
61
61
|
const require_flattenDeep = require("./array/flattenDeep.js");
|
package/dist/compat/compat.mjs
CHANGED
|
@@ -54,8 +54,8 @@ import { head } from "./array/head.mjs";
|
|
|
54
54
|
import "./array/first.mjs";
|
|
55
55
|
import { flattenDepth } from "./array/flattenDepth.mjs";
|
|
56
56
|
import { map } from "./array/map.mjs";
|
|
57
|
-
import { flatMap } from "./array/flatMap.mjs";
|
|
58
57
|
import { flatMapDepth } from "./array/flatMapDepth.mjs";
|
|
58
|
+
import { flatMap } from "./array/flatMap.mjs";
|
|
59
59
|
import { flatMapDeep } from "./array/flatMapDeep.mjs";
|
|
60
60
|
import { flatten } from "./array/flatten.mjs";
|
|
61
61
|
import { flattenDeep } from "./array/flattenDeep.mjs";
|
package/dist/compat/index.js
CHANGED
|
@@ -54,8 +54,8 @@ const require_findLastIndex = require("./array/findLastIndex.js");
|
|
|
54
54
|
const require_head = require("./array/head.js");
|
|
55
55
|
const require_flattenDepth = require("./array/flattenDepth.js");
|
|
56
56
|
const require_map = require("./array/map.js");
|
|
57
|
-
const require_flatMap = require("./array/flatMap.js");
|
|
58
57
|
const require_flatMapDepth = require("./array/flatMapDepth.js");
|
|
58
|
+
const require_flatMap = require("./array/flatMap.js");
|
|
59
59
|
const require_flatMapDeep = require("./array/flatMapDeep.js");
|
|
60
60
|
const require_flatten = require("./array/flatten.js");
|
|
61
61
|
const require_flattenDeep = require("./array/flattenDeep.js");
|
package/dist/compat/index.mjs
CHANGED
|
@@ -50,8 +50,8 @@ import { findLastIndex } from "./array/findLastIndex.mjs";
|
|
|
50
50
|
import { head } from "./array/head.mjs";
|
|
51
51
|
import { flattenDepth } from "./array/flattenDepth.mjs";
|
|
52
52
|
import { map } from "./array/map.mjs";
|
|
53
|
-
import { flatMap } from "./array/flatMap.mjs";
|
|
54
53
|
import { flatMapDepth } from "./array/flatMapDepth.mjs";
|
|
54
|
+
import { flatMap } from "./array/flatMap.mjs";
|
|
55
55
|
import { flatMapDeep } from "./array/flatMapDeep.mjs";
|
|
56
56
|
import { flatten } from "./array/flatten.mjs";
|
|
57
57
|
import { flattenDeep } from "./array/flattenDeep.mjs";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_isIterable = require("../../predicate/isIterable.js");
|
|
1
2
|
const require_isArrayLike = require("../predicate/isArrayLike.js");
|
|
2
3
|
const require_isMap = require("../predicate/isMap.js");
|
|
3
4
|
const require_isSet = require("../predicate/isSet.js");
|
|
@@ -17,7 +18,10 @@ const require_isSet = require("../predicate/isSet.js");
|
|
|
17
18
|
function toArray(value) {
|
|
18
19
|
if (value == null) return [];
|
|
19
20
|
if (require_isArrayLike.isArrayLike(value) || require_isMap.isMap(value) || require_isSet.isSet(value)) return Array.from(value);
|
|
20
|
-
if (typeof value === "object")
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
if (require_isIterable.isIterable(value)) return Array.from(value);
|
|
23
|
+
return Object.values(value);
|
|
24
|
+
}
|
|
21
25
|
return [];
|
|
22
26
|
}
|
|
23
27
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isIterable } from "../../predicate/isIterable.mjs";
|
|
1
2
|
import { isArrayLike } from "../predicate/isArrayLike.mjs";
|
|
2
3
|
import { isMap } from "../predicate/isMap.mjs";
|
|
3
4
|
import { isSet } from "../predicate/isSet.mjs";
|
|
@@ -17,7 +18,10 @@ import { isSet } from "../predicate/isSet.mjs";
|
|
|
17
18
|
function toArray(value) {
|
|
18
19
|
if (value == null) return [];
|
|
19
20
|
if (isArrayLike(value) || isMap(value) || isSet(value)) return Array.from(value);
|
|
20
|
-
if (typeof value === "object")
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
if (isIterable(value)) return Array.from(value);
|
|
23
|
+
return Object.values(value);
|
|
24
|
+
}
|
|
21
25
|
return [];
|
|
22
26
|
}
|
|
23
27
|
//#endregion
|
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
function toString(value) {
|
|
19
19
|
if (value == null) return "";
|
|
20
|
+
return baseToString(value);
|
|
21
|
+
}
|
|
22
|
+
function baseToString(value) {
|
|
20
23
|
if (typeof value === "string") return value;
|
|
21
|
-
if (Array.isArray(value)) return value.map(
|
|
24
|
+
if (Array.isArray(value)) return value.map(baseToString).join(",");
|
|
22
25
|
const result = String(value);
|
|
23
26
|
if (result === "0" && Object.is(Number(value), -0)) return "-0";
|
|
24
27
|
return result;
|
|
@@ -17,8 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
function toString(value) {
|
|
19
19
|
if (value == null) return "";
|
|
20
|
+
return baseToString(value);
|
|
21
|
+
}
|
|
22
|
+
function baseToString(value) {
|
|
20
23
|
if (typeof value === "string") return value;
|
|
21
|
-
if (Array.isArray(value)) return value.map(
|
|
24
|
+
if (Array.isArray(value)) return value.map(baseToString).join(",");
|
|
22
25
|
const result = String(value);
|
|
23
26
|
if (result === "0" && Object.is(Number(value), -0)) return "-0";
|
|
24
27
|
return result;
|
package/dist/function/retry.js
CHANGED
|
@@ -35,8 +35,10 @@ async function retry(func, _options) {
|
|
|
35
35
|
} catch (err) {
|
|
36
36
|
error = err;
|
|
37
37
|
if (!shouldRetry(err, attempts)) throw err;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (attempts < retries) {
|
|
39
|
+
const currentDelay = typeof delay$1 === "function" ? delay$1(attempts) : delay$1;
|
|
40
|
+
await require_delay.delay(currentDelay);
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
throw error;
|
package/dist/function/retry.mjs
CHANGED
|
@@ -35,7 +35,7 @@ async function retry(func, _options) {
|
|
|
35
35
|
} catch (err) {
|
|
36
36
|
error = err;
|
|
37
37
|
if (!shouldRetry(err, attempts)) throw err;
|
|
38
|
-
await delay(typeof delay$1 === "function" ? delay$1(attempts) : delay$1);
|
|
38
|
+
if (attempts < retries) await delay(typeof delay$1 === "function" ? delay$1(attempts) : delay$1);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
throw error;
|
package/dist/index.d.mts
CHANGED
|
@@ -121,7 +121,10 @@ import { pick } from "./object/pick.mjs";
|
|
|
121
121
|
import { pickBy } from "./object/pickBy.mjs";
|
|
122
122
|
import { sortKeys } from "./object/sortKeys.mjs";
|
|
123
123
|
import { toCamelCaseKeys } from "./object/toCamelCaseKeys.mjs";
|
|
124
|
+
import { toConstantCaseKeys } from "./object/toConstantCaseKeys.mjs";
|
|
125
|
+
import { toKebabCaseKeys } from "./object/toKebabCaseKeys.mjs";
|
|
124
126
|
import { toMerged } from "./object/toMerged.mjs";
|
|
127
|
+
import { toPascalCaseKeys } from "./object/toPascalCaseKeys.mjs";
|
|
125
128
|
import { toSnakeCaseKeys } from "./object/toSnakeCaseKeys.mjs";
|
|
126
129
|
import { isArrayBuffer } from "./predicate/isArrayBuffer.mjs";
|
|
127
130
|
import { isBlob } from "./predicate/isBlob.mjs";
|
|
@@ -185,4 +188,4 @@ import { words } from "./string/words.mjs";
|
|
|
185
188
|
import { attempt } from "./util/attempt.mjs";
|
|
186
189
|
import { attemptAsync } from "./util/attemptAsync.mjs";
|
|
187
190
|
import { invariant } from "./util/invariant.mjs";
|
|
188
|
-
export { AbortError, DebounceOptions, DebouncedFunction, MemoizeCache, Mutex, Semaphore, ThrottleOptions, ThrottledFunction, TimeoutError, after, allKeyed, ary, invariant as assert, asyncNoop, at, attempt, attemptAsync, before, camelCase, capitalize, cartesianProduct, chunk, chunkBy, clamp, clone, cloneDeep, cloneDeepWith, combinations, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, escape, escapeRegExp, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowRight, forEachAsync, forEachRight, groupBy, head, identity, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, percentile, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, remove, rest, retry, reverseString, round, sample, sampleSize, shuffle, snakeCase, sortBy, sortKeys, spread, startCase, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeout, toCamelCaseKeys, toFilled, toMerged, toSnakeCaseKeys, trim, trimEnd, trimStart, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, upperCase, upperFirst, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith };
|
|
191
|
+
export { AbortError, DebounceOptions, DebouncedFunction, MemoizeCache, Mutex, Semaphore, ThrottleOptions, ThrottledFunction, TimeoutError, after, allKeyed, ary, invariant as assert, asyncNoop, at, attempt, attemptAsync, before, camelCase, capitalize, cartesianProduct, chunk, chunkBy, clamp, clone, cloneDeep, cloneDeepWith, combinations, compact, constantCase, countBy, curry, curryRight, debounce, deburr, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, escape, escapeRegExp, fill, filterAsync, findKey, flatMap, flatMapAsync, flatMapDeep, flatten, flattenDeep, flattenObject, flow, flowRight, forEachAsync, forEachRight, groupBy, head, identity, inRange, initial, intersection, intersectionBy, intersectionWith, invariant, invert, isArrayBuffer, isBlob, isBoolean, isBrowser, isBuffer, isDate, isEmptyObject, isEqual, isEqualWith, isError, isFile, isFunction, isIterable, isJSON, isJSONArray, isJSONObject, isJSONValue, isLength, isMap, isNil, isNode, isNotNil, isNull, isNumber, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSubset, isSubsetWith, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, kebabCase, keyBy, last, limitAsync, lowerCase, lowerFirst, mapAsync, mapKeys, mapValues, maxBy, mean, meanBy, median, medianBy, memoize, merge, mergeWith, minBy, negate, noop, omit, omitBy, once, orderBy, pad, partial, partialRight, partition, pascalCase, percentile, pick, pickBy, pull, pullAt, random, randomInt, range, rangeRight, reduceAsync, remove, rest, retry, reverseString, round, sample, sampleSize, shuffle, snakeCase, sortBy, sortKeys, spread, startCase, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeout, toCamelCaseKeys, toConstantCaseKeys, toFilled, toKebabCaseKeys, toMerged, toPascalCaseKeys, toSnakeCaseKeys, trim, trimEnd, trimStart, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, upperCase, upperFirst, windowed, withTimeout, without, words, xor, xorBy, xorWith, zip, zipObject, zipWith };
|