es-toolkit 1.10.1 → 1.11.0-dev.261
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/CHANGELOG.md +33 -0
- package/compat.d.ts +1 -0
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.mjs +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.js +1 -0
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +2 -2
- package/dist/array/dropRight.js +5 -1
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +2 -2
- package/dist/array/dropRightWhile.js +6 -14
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -3
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.d.mts +10 -7
- package/dist/array/fill.d.ts +10 -7
- package/dist/array/fill.js +7 -6
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +2 -2
- package/dist/array/flatMap.d.mts +23 -0
- package/dist/array/flatMap.d.ts +23 -0
- package/dist/array/flatMap.js +52 -0
- package/dist/array/flatMap.js.map +1 -0
- package/dist/array/flatMap.mjs +9 -0
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.mjs +1 -1
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +30 -14
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +41 -37
- package/dist/array/initial.mjs +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/last.mjs +1 -1
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/orderBy.mjs +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.mjs +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/toFilled.mjs +1 -1
- package/dist/array/union.mjs +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.d.mts +1 -1
- package/dist/array/uniqBy.d.ts +1 -1
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +2 -2
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/array/without.mjs +1 -1
- package/dist/array/xor.mjs +1 -1
- package/dist/array/xorBy.mjs +1 -1
- package/dist/array/xorWith.mjs +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/{chunk-S3CORED5.mjs → chunk-3EZAFZG3.mjs} +2 -1
- package/dist/{chunk-S3CORED5.mjs.map → chunk-3EZAFZG3.mjs.map} +1 -1
- package/dist/{chunk-2MM5EJJX.mjs → chunk-424M7IR7.mjs} +23 -2
- package/dist/chunk-4OIZM4HS.mjs +1 -0
- package/dist/{chunk-GDC64SYJ.mjs → chunk-5ASRKEB4.mjs} +1 -1
- package/dist/{chunk-GDC64SYJ.mjs.map → chunk-5ASRKEB4.mjs.map} +1 -1
- package/dist/{chunk-OXAZEEGP.mjs → chunk-B4COTK4K.mjs} +1 -1
- package/dist/{chunk-OXAZEEGP.mjs.map → chunk-B4COTK4K.mjs.map} +1 -1
- package/dist/chunk-DDH7K4QM.mjs +1 -0
- package/dist/chunk-F47GLYUU.mjs +1 -0
- package/dist/chunk-J3GE7DEU.mjs +22 -0
- package/dist/chunk-J3GE7DEU.mjs.map +1 -0
- package/dist/chunk-KIOYQRMQ.mjs +12 -0
- package/dist/chunk-KIOYQRMQ.mjs.map +1 -0
- package/dist/chunk-M7SBBYV2.mjs +14 -0
- package/dist/chunk-M7SBBYV2.mjs.map +1 -0
- package/dist/{chunk-IZAD2S7R.mjs → chunk-MY4G7R3I.mjs} +2 -2
- package/dist/{chunk-74WWMNZS.mjs → chunk-OLX53VEF.mjs} +4 -2
- package/dist/{chunk-74WWMNZS.mjs.map → chunk-OLX53VEF.mjs.map} +1 -1
- package/dist/chunk-OXZCMC5I.mjs +13 -0
- package/dist/{chunk-JEKUA56R.mjs.map → chunk-OXZCMC5I.mjs.map} +1 -1
- package/dist/chunk-QXTNZR7B.mjs +25 -0
- package/dist/chunk-QXTNZR7B.mjs.map +1 -0
- package/dist/{chunk-QZITBKWX.mjs → chunk-U7V3G7CR.mjs} +2 -2
- package/dist/chunk-UY76KTPE.mjs +13 -0
- package/dist/chunk-UY76KTPE.mjs.map +1 -0
- package/dist/chunk-XT74R35S.mjs +1 -0
- package/dist/chunk-XT74R35S.mjs.map +1 -0
- package/dist/chunk-XWPCDIFC.mjs +18 -0
- package/dist/chunk-XWPCDIFC.mjs.map +1 -0
- package/dist/chunk-YFN6KOC4.mjs +15 -0
- package/dist/chunk-YFN6KOC4.mjs.map +1 -0
- package/dist/compat/index.d.mts +360 -1
- package/dist/compat/index.d.ts +360 -1
- package/dist/compat/index.js +240 -15
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +235 -82
- package/dist/compat/index.mjs.map +1 -1
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/TimeoutError.d.mts +9 -0
- package/dist/error/TimeoutError.d.ts +9 -0
- package/dist/error/TimeoutError.js +36 -0
- package/dist/error/TimeoutError.js.map +1 -0
- package/dist/error/TimeoutError.mjs +8 -0
- package/dist/error/TimeoutError.mjs.map +1 -0
- package/dist/error/index.d.mts +1 -0
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.js +12 -2
- package/dist/error/index.js.map +1 -1
- package/dist/error/index.mjs +7 -3
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.mjs +4 -4
- package/dist/function/negate.mjs +1 -1
- package/dist/function/noop.mjs +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +99 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -82
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +12 -12
- package/dist/math/mean.d.mts +1 -1
- package/dist/math/mean.d.ts +1 -1
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +2 -2
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +3 -3
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.mjs +1 -1
- package/dist/math/range.mjs +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.mjs +1 -1
- package/dist/math/sumBy.mjs +1 -1
- package/dist/object/clone.mjs +1 -1
- package/dist/object/index.js +3 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +6 -6
- package/dist/object/invert.js +3 -1
- package/dist/object/invert.js.map +1 -1
- package/dist/object/invert.mjs +2 -2
- package/dist/object/omit.mjs +2 -2
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.mjs +1 -1
- package/dist/predicate/isEqual.mjs +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.d.mts +1 -0
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/index.js +47 -2
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +9 -3
- package/dist/promise/timeout.d.mts +10 -0
- package/dist/promise/timeout.d.ts +10 -0
- package/dist/promise/timeout.js +92 -0
- package/dist/promise/timeout.js.map +1 -0
- package/dist/promise/timeout.mjs +11 -0
- package/dist/promise/timeout.mjs.map +1 -0
- package/dist/promise/withTimeout.d.mts +22 -0
- package/dist/promise/withTimeout.d.ts +22 -0
- package/dist/promise/withTimeout.js +99 -0
- package/dist/promise/withTimeout.js.map +1 -0
- package/dist/promise/withTimeout.mjs +12 -0
- package/dist/promise/withTimeout.mjs.map +1 -0
- package/dist/string/camelCase.mjs +1 -1
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +21 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +13 -9
- package/dist/string/kebabCase.mjs +1 -1
- package/dist/string/lowerCase.mjs +1 -1
- package/dist/string/snakeCase.mjs +1 -1
- package/dist/string/startCase.d.mts +16 -0
- package/dist/string/startCase.d.ts +16 -0
- package/dist/string/startCase.js +54 -0
- package/dist/string/startCase.js.map +1 -0
- package/dist/string/startCase.mjs +9 -0
- package/dist/string/startCase.mjs.map +1 -0
- package/package.json +3 -5
- package/dist/chunk-2MRZANXZ.mjs +0 -1
- package/dist/chunk-ARZ5BDR6.mjs +0 -1
- package/dist/chunk-C4WE4GLC.mjs +0 -14
- package/dist/chunk-C4WE4GLC.mjs.map +0 -1
- package/dist/chunk-FZEZH22H.mjs +0 -1
- package/dist/chunk-JE6JKZU3.mjs +0 -15
- package/dist/chunk-JE6JKZU3.mjs.map +0 -1
- package/dist/chunk-JEKUA56R.mjs +0 -9
- package/dist/chunk-QKYYOLJ6.mjs +0 -1
- /package/dist/{chunk-2MM5EJJX.mjs.map → array/flatMap.mjs.map} +0 -0
- /package/dist/{chunk-2MRZANXZ.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
- /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
- /package/dist/{chunk-FZEZH22H.mjs.map → chunk-DDH7K4QM.mjs.map} +0 -0
- /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
- /package/dist/{chunk-IZAD2S7R.mjs.map → chunk-MY4G7R3I.mjs.map} +0 -0
- /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
package/dist/compat/index.js
CHANGED
|
@@ -30,11 +30,32 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
30
30
|
return to;
|
|
31
31
|
};
|
|
32
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
33
53
|
|
|
34
54
|
// src/compat/index.ts
|
|
35
55
|
var compat_exports = {};
|
|
36
56
|
__export(compat_exports, {
|
|
37
57
|
AbortError: () => AbortError,
|
|
58
|
+
TimeoutError: () => TimeoutError,
|
|
38
59
|
camelCase: () => camelCase,
|
|
39
60
|
capitalize: () => capitalize,
|
|
40
61
|
chunk: () => chunk2,
|
|
@@ -51,10 +72,13 @@ __export(compat_exports, {
|
|
|
51
72
|
dropRight: () => dropRight,
|
|
52
73
|
dropRightWhile: () => dropRightWhile,
|
|
53
74
|
dropWhile: () => dropWhile,
|
|
75
|
+
endsWith: () => endsWith,
|
|
54
76
|
fill: () => fill,
|
|
77
|
+
flatMap: () => flatMap,
|
|
55
78
|
flatten: () => flatten,
|
|
56
79
|
flattenDeep: () => flattenDeep,
|
|
57
80
|
forEachRight: () => forEachRight,
|
|
81
|
+
get: () => get,
|
|
58
82
|
groupBy: () => groupBy,
|
|
59
83
|
head: () => head,
|
|
60
84
|
inRange: () => inRange,
|
|
@@ -91,8 +115,11 @@ __export(compat_exports, {
|
|
|
91
115
|
round: () => round,
|
|
92
116
|
sample: () => sample,
|
|
93
117
|
sampleSize: () => sampleSize,
|
|
118
|
+
set: () => set,
|
|
94
119
|
shuffle: () => shuffle,
|
|
95
120
|
snakeCase: () => snakeCase,
|
|
121
|
+
startCase: () => startCase,
|
|
122
|
+
startsWith: () => startsWith,
|
|
96
123
|
sum: () => sum,
|
|
97
124
|
sumBy: () => sumBy,
|
|
98
125
|
tail: () => tail,
|
|
@@ -110,12 +137,14 @@ __export(compat_exports, {
|
|
|
110
137
|
uniqWith: () => uniqWith,
|
|
111
138
|
unzip: () => unzip,
|
|
112
139
|
unzipWith: () => unzipWith,
|
|
140
|
+
withTimeout: () => withTimeout,
|
|
113
141
|
without: () => without,
|
|
114
142
|
xor: () => xor,
|
|
115
143
|
xorBy: () => xorBy,
|
|
116
144
|
xorWith: () => xorWith,
|
|
117
145
|
zip: () => zip,
|
|
118
146
|
zipObject: () => zipObject,
|
|
147
|
+
zipObjectDeep: () => zipObjectDeep,
|
|
119
148
|
zipWith: () => zipWith
|
|
120
149
|
});
|
|
121
150
|
module.exports = __toCommonJS(compat_exports);
|
|
@@ -182,12 +211,27 @@ function differenceWith(firstArr, secondArr, areItemsEqual) {
|
|
|
182
211
|
|
|
183
212
|
// src/array/drop.ts
|
|
184
213
|
function drop(arr, itemsCount) {
|
|
214
|
+
itemsCount = Math.max(itemsCount, 0);
|
|
185
215
|
return arr.slice(itemsCount);
|
|
186
216
|
}
|
|
187
217
|
|
|
188
218
|
// src/array/dropRight.ts
|
|
189
219
|
function dropRight(arr, itemsCount) {
|
|
190
|
-
|
|
220
|
+
itemsCount = Math.min(-itemsCount, 0);
|
|
221
|
+
if (itemsCount === 0) {
|
|
222
|
+
return arr.slice();
|
|
223
|
+
}
|
|
224
|
+
return arr.slice(0, itemsCount);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/array/dropRightWhile.ts
|
|
228
|
+
function dropRightWhile(arr, canContinueDropping) {
|
|
229
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
230
|
+
if (!canContinueDropping(arr[i])) {
|
|
231
|
+
return arr.slice(0, i + 1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return [];
|
|
191
235
|
}
|
|
192
236
|
|
|
193
237
|
// src/array/dropWhile.ts
|
|
@@ -199,21 +243,15 @@ function dropWhile(arr, canContinueDropping) {
|
|
|
199
243
|
return arr.slice(dropEndIndex);
|
|
200
244
|
}
|
|
201
245
|
|
|
202
|
-
// src/array/dropRightWhile.ts
|
|
203
|
-
function dropRightWhile(arr, canContinueDropping) {
|
|
204
|
-
const reversed = arr.slice().reverse();
|
|
205
|
-
const dropped = dropWhile(reversed, canContinueDropping);
|
|
206
|
-
return dropped.slice().reverse();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
246
|
// src/array/fill.ts
|
|
210
|
-
function fill(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
247
|
+
function fill(array, value, start = 0, end = array.length) {
|
|
248
|
+
const length = array.length;
|
|
249
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
250
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
251
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
252
|
+
array[i] = value;
|
|
215
253
|
}
|
|
216
|
-
return
|
|
254
|
+
return array;
|
|
217
255
|
}
|
|
218
256
|
|
|
219
257
|
// src/array/flatten.ts
|
|
@@ -233,6 +271,11 @@ function flatten(arr, depth = 1) {
|
|
|
233
271
|
return result;
|
|
234
272
|
}
|
|
235
273
|
|
|
274
|
+
// src/array/flatMap.ts
|
|
275
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
276
|
+
return flatten(arr.map((item) => iteratee(item)), depth);
|
|
277
|
+
}
|
|
278
|
+
|
|
236
279
|
// src/array/flattenDeep.ts
|
|
237
280
|
function flattenDeep(arr) {
|
|
238
281
|
return flatten(arr, Infinity);
|
|
@@ -640,6 +683,14 @@ var AbortError = class extends Error {
|
|
|
640
683
|
}
|
|
641
684
|
};
|
|
642
685
|
|
|
686
|
+
// src/error/TimeoutError.ts
|
|
687
|
+
var TimeoutError = class extends Error {
|
|
688
|
+
constructor(message = "The operation was timed out") {
|
|
689
|
+
super(message);
|
|
690
|
+
this.name = "TimeoutError";
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
|
|
643
694
|
// src/function/debounce.ts
|
|
644
695
|
function debounce(func, debounceMs, { signal } = {}) {
|
|
645
696
|
let timeoutId = null;
|
|
@@ -825,7 +876,9 @@ function pickBy(obj, shouldPick) {
|
|
|
825
876
|
// src/object/invert.ts
|
|
826
877
|
function invert(obj) {
|
|
827
878
|
const result = {};
|
|
828
|
-
|
|
879
|
+
const keys = Object.keys(obj);
|
|
880
|
+
for (let i = 0; i < keys.length; i++) {
|
|
881
|
+
const key = keys[i];
|
|
829
882
|
const value = obj[key];
|
|
830
883
|
result[value] = key;
|
|
831
884
|
}
|
|
@@ -940,6 +993,21 @@ function delay(ms, { signal } = {}) {
|
|
|
940
993
|
});
|
|
941
994
|
}
|
|
942
995
|
|
|
996
|
+
// src/promise/timeout.ts
|
|
997
|
+
function timeout(ms) {
|
|
998
|
+
return __async(this, null, function* () {
|
|
999
|
+
yield delay(ms);
|
|
1000
|
+
throw new TimeoutError();
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// src/promise/withTimeout.ts
|
|
1005
|
+
function withTimeout(run, ms) {
|
|
1006
|
+
return __async(this, null, function* () {
|
|
1007
|
+
return Promise.race([run(), timeout(ms)]);
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
|
|
943
1011
|
// src/string/capitalize.ts
|
|
944
1012
|
var capitalize = (str) => {
|
|
945
1013
|
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
@@ -980,6 +1048,23 @@ var lowerCase = (str) => {
|
|
|
980
1048
|
return words.map((word) => word.toLowerCase()).join(" ");
|
|
981
1049
|
};
|
|
982
1050
|
|
|
1051
|
+
// src/string/startCase.ts
|
|
1052
|
+
function startCase(str) {
|
|
1053
|
+
const words = getWords(str.trim());
|
|
1054
|
+
let result = "";
|
|
1055
|
+
for (const word of words) {
|
|
1056
|
+
if (result) {
|
|
1057
|
+
result += " ";
|
|
1058
|
+
}
|
|
1059
|
+
if (word === word.toUpperCase()) {
|
|
1060
|
+
result += word;
|
|
1061
|
+
} else {
|
|
1062
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
return result;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
983
1068
|
// src/compat/array/chunk.ts
|
|
984
1069
|
function chunk2(arr, size = 1) {
|
|
985
1070
|
size = Math.max(Math.floor(size), 0);
|
|
@@ -988,9 +1073,141 @@ function chunk2(arr, size = 1) {
|
|
|
988
1073
|
}
|
|
989
1074
|
return chunk(arr, size);
|
|
990
1075
|
}
|
|
1076
|
+
|
|
1077
|
+
// src/compat/_internal/isIndex.ts
|
|
1078
|
+
var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
1079
|
+
function isIndex(value) {
|
|
1080
|
+
switch (typeof value) {
|
|
1081
|
+
case "number": {
|
|
1082
|
+
return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
1083
|
+
}
|
|
1084
|
+
case "symbol": {
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
case "string": {
|
|
1088
|
+
return IS_UNSIGNED_INTEGER.test(value);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// src/compat/_internal/toPath.ts
|
|
1094
|
+
function toPath(deepKey) {
|
|
1095
|
+
const ESCAPE_REGEXP = /\\(\\)?/g;
|
|
1096
|
+
const PROPERTY_REGEXP = RegExp(
|
|
1097
|
+
// Match anything that isn't a dot or bracket.
|
|
1098
|
+
`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
|
|
1099
|
+
"g"
|
|
1100
|
+
);
|
|
1101
|
+
const result = [];
|
|
1102
|
+
if (deepKey[0] === ".") {
|
|
1103
|
+
result.push("");
|
|
1104
|
+
}
|
|
1105
|
+
let match;
|
|
1106
|
+
let lastIndex = 0;
|
|
1107
|
+
let count = 0;
|
|
1108
|
+
while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
|
|
1109
|
+
let [key, expr, quote, substr] = match;
|
|
1110
|
+
if (quote) {
|
|
1111
|
+
key = substr.replace(ESCAPE_REGEXP, "$1");
|
|
1112
|
+
} else if (expr) {
|
|
1113
|
+
key = expr;
|
|
1114
|
+
}
|
|
1115
|
+
result.push(key);
|
|
1116
|
+
if (PROPERTY_REGEXP.lastIndex === lastIndex) {
|
|
1117
|
+
PROPERTY_REGEXP.lastIndex++;
|
|
1118
|
+
} else {
|
|
1119
|
+
lastIndex = PROPERTY_REGEXP.lastIndex;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// src/compat/object/set.ts
|
|
1126
|
+
function set(obj, path, value) {
|
|
1127
|
+
const resolvedPath = Array.isArray(path) ? path : typeof path === "string" ? toPath(path) : [path];
|
|
1128
|
+
let current = obj;
|
|
1129
|
+
for (let i = 0; i < resolvedPath.length - 1; i++) {
|
|
1130
|
+
const key = resolvedPath[i];
|
|
1131
|
+
const nextKey = resolvedPath[i + 1];
|
|
1132
|
+
if (current[key] == null) {
|
|
1133
|
+
current[key] = isIndex(nextKey) ? [] : {};
|
|
1134
|
+
}
|
|
1135
|
+
current = current[key];
|
|
1136
|
+
}
|
|
1137
|
+
const lastKey = resolvedPath[resolvedPath.length - 1];
|
|
1138
|
+
current[lastKey] = value;
|
|
1139
|
+
return obj;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// src/compat/array/zipObjectDeep.ts
|
|
1143
|
+
function zipObjectDeep(keys, values) {
|
|
1144
|
+
const result = {};
|
|
1145
|
+
const zipped = zip(keys, values);
|
|
1146
|
+
for (let i = 0; i < zipped.length; i++) {
|
|
1147
|
+
const [key, value] = zipped[i];
|
|
1148
|
+
if (key != null) {
|
|
1149
|
+
set(result, key, value);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return result;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// src/compat/_internal/isDeepKey.ts
|
|
1156
|
+
var IS_PLAIN = /^\w*$/;
|
|
1157
|
+
var IS_DEEP = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
1158
|
+
function isDeepKey(key) {
|
|
1159
|
+
switch (typeof key) {
|
|
1160
|
+
case "number":
|
|
1161
|
+
case "symbol": {
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
case "string": {
|
|
1165
|
+
return !IS_PLAIN.test(key) && IS_DEEP.test(key);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// src/compat/object/get.ts
|
|
1171
|
+
function get(object, path, defaultValue) {
|
|
1172
|
+
let resolvedPath;
|
|
1173
|
+
if (Array.isArray(path)) {
|
|
1174
|
+
resolvedPath = path;
|
|
1175
|
+
} else if (typeof path === "string" && isDeepKey(path) && (object == null ? void 0 : object[path]) == null) {
|
|
1176
|
+
resolvedPath = toPath(path);
|
|
1177
|
+
} else {
|
|
1178
|
+
resolvedPath = [path];
|
|
1179
|
+
}
|
|
1180
|
+
if (resolvedPath.length === 0) {
|
|
1181
|
+
return defaultValue;
|
|
1182
|
+
}
|
|
1183
|
+
let current = object;
|
|
1184
|
+
let index;
|
|
1185
|
+
for (index = 0; index < resolvedPath.length && current != null; index++) {
|
|
1186
|
+
let key = resolvedPath[index];
|
|
1187
|
+
if (Object.is(key.valueOf(), -0)) {
|
|
1188
|
+
key = "-0";
|
|
1189
|
+
}
|
|
1190
|
+
current = current[key];
|
|
1191
|
+
}
|
|
1192
|
+
if (current === null && index === resolvedPath.length) {
|
|
1193
|
+
return current;
|
|
1194
|
+
}
|
|
1195
|
+
return current != null ? current : defaultValue;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// src/compat/string/startsWith.ts
|
|
1199
|
+
var startsWith = (str, target, position = 0) => {
|
|
1200
|
+
return str.startsWith(target, position);
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
// src/compat/string/endsWith.ts
|
|
1204
|
+
var endsWith = (str, target, position = str.length) => {
|
|
1205
|
+
return str.endsWith(target, position);
|
|
1206
|
+
};
|
|
991
1207
|
// Annotate the CommonJS export names for ESM import in node:
|
|
992
1208
|
0 && (module.exports = {
|
|
993
1209
|
AbortError,
|
|
1210
|
+
TimeoutError,
|
|
994
1211
|
camelCase,
|
|
995
1212
|
capitalize,
|
|
996
1213
|
chunk,
|
|
@@ -1007,10 +1224,13 @@ function chunk2(arr, size = 1) {
|
|
|
1007
1224
|
dropRight,
|
|
1008
1225
|
dropRightWhile,
|
|
1009
1226
|
dropWhile,
|
|
1227
|
+
endsWith,
|
|
1010
1228
|
fill,
|
|
1229
|
+
flatMap,
|
|
1011
1230
|
flatten,
|
|
1012
1231
|
flattenDeep,
|
|
1013
1232
|
forEachRight,
|
|
1233
|
+
get,
|
|
1014
1234
|
groupBy,
|
|
1015
1235
|
head,
|
|
1016
1236
|
inRange,
|
|
@@ -1047,8 +1267,11 @@ function chunk2(arr, size = 1) {
|
|
|
1047
1267
|
round,
|
|
1048
1268
|
sample,
|
|
1049
1269
|
sampleSize,
|
|
1270
|
+
set,
|
|
1050
1271
|
shuffle,
|
|
1051
1272
|
snakeCase,
|
|
1273
|
+
startCase,
|
|
1274
|
+
startsWith,
|
|
1052
1275
|
sum,
|
|
1053
1276
|
sumBy,
|
|
1054
1277
|
tail,
|
|
@@ -1066,12 +1289,14 @@ function chunk2(arr, size = 1) {
|
|
|
1066
1289
|
uniqWith,
|
|
1067
1290
|
unzip,
|
|
1068
1291
|
unzipWith,
|
|
1292
|
+
withTimeout,
|
|
1069
1293
|
without,
|
|
1070
1294
|
xor,
|
|
1071
1295
|
xorBy,
|
|
1072
1296
|
xorWith,
|
|
1073
1297
|
zip,
|
|
1074
1298
|
zipObject,
|
|
1299
|
+
zipObjectDeep,
|
|
1075
1300
|
zipWith
|
|
1076
1301
|
});
|
|
1077
1302
|
//# sourceMappingURL=index.js.map
|