es-toolkit 1.13.0 → 1.13.1-dev.295
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 +6 -0
- package/dist/array/index.mjs +35 -35
- package/dist/browser.js +230 -13
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +27 -26
- package/dist/browser.mjs.map +1 -1
- package/dist/chunk-NKLIE2OI.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs.map +1 -0
- package/dist/{chunk-SPKLWVNJ.mjs → chunk-QJZPJCVU.mjs} +289 -64
- package/dist/chunk-QJZPJCVU.mjs.map +1 -0
- package/dist/compat/index.mjs +69 -268
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/index.mjs +56 -56
- package/package.json +1 -1
- package/umd/browser.global.js +1 -1
- package/dist/chunk-SPKLWVNJ.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
package/dist/array/index.mjs
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
+
import {
|
|
3
|
+
zipObject
|
|
4
|
+
} from "../chunk-6GWEY5EL.mjs";
|
|
5
|
+
import {
|
|
6
|
+
zipWith
|
|
7
|
+
} from "../chunk-4KYXHZ4R.mjs";
|
|
8
|
+
import {
|
|
9
|
+
unzip
|
|
10
|
+
} from "../chunk-UYZKMBDO.mjs";
|
|
2
11
|
import {
|
|
3
12
|
unzipWith
|
|
4
13
|
} from "../chunk-IFNXROZR.mjs";
|
|
@@ -18,11 +27,11 @@ import {
|
|
|
18
27
|
zip
|
|
19
28
|
} from "../chunk-IDCUZVJL.mjs";
|
|
20
29
|
import {
|
|
21
|
-
|
|
22
|
-
} from "../chunk-
|
|
30
|
+
takeRightWhile
|
|
31
|
+
} from "../chunk-NTLX2MPV.mjs";
|
|
23
32
|
import {
|
|
24
|
-
|
|
25
|
-
} from "../chunk-
|
|
33
|
+
takeWhile
|
|
34
|
+
} from "../chunk-2IXFGSUA.mjs";
|
|
26
35
|
import {
|
|
27
36
|
toFilled
|
|
28
37
|
} from "../chunk-OP4OAKQJ.mjs";
|
|
@@ -35,6 +44,9 @@ import {
|
|
|
35
44
|
import {
|
|
36
45
|
unionWith
|
|
37
46
|
} from "../chunk-2ZCITDMK.mjs";
|
|
47
|
+
import {
|
|
48
|
+
uniqWith
|
|
49
|
+
} from "../chunk-237HGSZS.mjs";
|
|
38
50
|
import {
|
|
39
51
|
uniq
|
|
40
52
|
} from "../chunk-DVK2N4KC.mjs";
|
|
@@ -42,11 +54,11 @@ import {
|
|
|
42
54
|
uniqBy
|
|
43
55
|
} from "../chunk-B4COTK4K.mjs";
|
|
44
56
|
import {
|
|
45
|
-
|
|
46
|
-
} from "../chunk-
|
|
57
|
+
orderBy
|
|
58
|
+
} from "../chunk-7B7W36UP.mjs";
|
|
47
59
|
import {
|
|
48
|
-
|
|
49
|
-
} from "../chunk-
|
|
60
|
+
partition
|
|
61
|
+
} from "../chunk-DN3NOZ3H.mjs";
|
|
50
62
|
import {
|
|
51
63
|
sample
|
|
52
64
|
} from "../chunk-2KNLZB7V.mjs";
|
|
@@ -68,11 +80,11 @@ import {
|
|
|
68
80
|
takeRight
|
|
69
81
|
} from "../chunk-IQLKIDXF.mjs";
|
|
70
82
|
import {
|
|
71
|
-
|
|
72
|
-
} from "../chunk-
|
|
83
|
+
initial
|
|
84
|
+
} from "../chunk-XPSOKBRZ.mjs";
|
|
73
85
|
import {
|
|
74
|
-
|
|
75
|
-
} from "../chunk-
|
|
86
|
+
intersection
|
|
87
|
+
} from "../chunk-FVVSE2F2.mjs";
|
|
76
88
|
import {
|
|
77
89
|
intersectionBy
|
|
78
90
|
} from "../chunk-O6UXZR3U.mjs";
|
|
@@ -92,14 +104,17 @@ import {
|
|
|
92
104
|
minBy
|
|
93
105
|
} from "../chunk-IJD7FE2Z.mjs";
|
|
94
106
|
import {
|
|
95
|
-
|
|
96
|
-
} from "../chunk-
|
|
107
|
+
fill
|
|
108
|
+
} from "../chunk-YFN6KOC4.mjs";
|
|
97
109
|
import {
|
|
98
|
-
|
|
99
|
-
} from "../chunk-
|
|
110
|
+
flatMap
|
|
111
|
+
} from "../chunk-UY76KTPE.mjs";
|
|
100
112
|
import {
|
|
101
113
|
flattenDeep
|
|
102
114
|
} from "../chunk-ML727RRJ.mjs";
|
|
115
|
+
import {
|
|
116
|
+
flatten
|
|
117
|
+
} from "../chunk-33MSBDC6.mjs";
|
|
103
118
|
import {
|
|
104
119
|
forEachRight
|
|
105
120
|
} from "../chunk-IEA53J7P.mjs";
|
|
@@ -110,11 +125,11 @@ import {
|
|
|
110
125
|
head
|
|
111
126
|
} from "../chunk-HM2JT2RX.mjs";
|
|
112
127
|
import {
|
|
113
|
-
|
|
114
|
-
} from "../chunk-
|
|
128
|
+
countBy
|
|
129
|
+
} from "../chunk-CRSKT4WW.mjs";
|
|
115
130
|
import {
|
|
116
|
-
|
|
117
|
-
} from "../chunk-
|
|
131
|
+
difference
|
|
132
|
+
} from "../chunk-JPUKH67K.mjs";
|
|
118
133
|
import {
|
|
119
134
|
differenceBy
|
|
120
135
|
} from "../chunk-LVWX5B43.mjs";
|
|
@@ -133,27 +148,12 @@ import {
|
|
|
133
148
|
import {
|
|
134
149
|
dropWhile
|
|
135
150
|
} from "../chunk-LJ2C6MVP.mjs";
|
|
136
|
-
import {
|
|
137
|
-
fill
|
|
138
|
-
} from "../chunk-YFN6KOC4.mjs";
|
|
139
|
-
import {
|
|
140
|
-
flatMap
|
|
141
|
-
} from "../chunk-UY76KTPE.mjs";
|
|
142
|
-
import {
|
|
143
|
-
flatten
|
|
144
|
-
} from "../chunk-33MSBDC6.mjs";
|
|
145
151
|
import {
|
|
146
152
|
chunk
|
|
147
153
|
} from "../chunk-E6C5EZQA.mjs";
|
|
148
154
|
import {
|
|
149
155
|
compact
|
|
150
156
|
} from "../chunk-DTJJIMKJ.mjs";
|
|
151
|
-
import {
|
|
152
|
-
countBy
|
|
153
|
-
} from "../chunk-CRSKT4WW.mjs";
|
|
154
|
-
import {
|
|
155
|
-
difference
|
|
156
|
-
} from "../chunk-JPUKH67K.mjs";
|
|
157
157
|
import "../chunk-24FKGR6U.mjs";
|
|
158
158
|
export {
|
|
159
159
|
chunk,
|
package/dist/browser.js
CHANGED
|
@@ -40,33 +40,37 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
// src/index.ts
|
|
44
|
-
var
|
|
45
|
-
__export(
|
|
43
|
+
// src/compat/index.ts
|
|
44
|
+
var compat_exports = {};
|
|
45
|
+
__export(compat_exports, {
|
|
46
46
|
AbortError: () => AbortError,
|
|
47
47
|
TimeoutError: () => TimeoutError,
|
|
48
48
|
camelCase: () => camelCase,
|
|
49
49
|
capitalize: () => capitalize,
|
|
50
|
-
chunk: () =>
|
|
50
|
+
chunk: () => chunk2,
|
|
51
51
|
clamp: () => clamp,
|
|
52
52
|
clone: () => clone,
|
|
53
53
|
compact: () => compact,
|
|
54
|
+
concat: () => concat,
|
|
54
55
|
countBy: () => countBy,
|
|
55
56
|
debounce: () => debounce,
|
|
56
57
|
delay: () => delay,
|
|
57
|
-
difference: () =>
|
|
58
|
+
difference: () => difference2,
|
|
58
59
|
differenceBy: () => differenceBy,
|
|
59
60
|
differenceWith: () => differenceWith,
|
|
60
61
|
drop: () => drop,
|
|
61
62
|
dropRight: () => dropRight,
|
|
62
63
|
dropRightWhile: () => dropRightWhile,
|
|
63
64
|
dropWhile: () => dropWhile,
|
|
65
|
+
endsWith: () => endsWith,
|
|
64
66
|
fill: () => fill,
|
|
67
|
+
first: () => head,
|
|
65
68
|
flatMap: () => flatMap,
|
|
66
69
|
flatten: () => flatten,
|
|
67
70
|
flattenDeep: () => flattenDeep,
|
|
68
71
|
flattenObject: () => flattenObject,
|
|
69
72
|
forEachRight: () => forEachRight,
|
|
73
|
+
get: () => get,
|
|
70
74
|
groupBy: () => groupBy,
|
|
71
75
|
head: () => head,
|
|
72
76
|
inRange: () => inRange,
|
|
@@ -80,15 +84,17 @@ __export(src_exports, {
|
|
|
80
84
|
isNil: () => isNil,
|
|
81
85
|
isNotNil: () => isNotNil,
|
|
82
86
|
isNull: () => isNull,
|
|
83
|
-
isPlainObject: () =>
|
|
87
|
+
isPlainObject: () => isPlainObject2,
|
|
84
88
|
isUndefined: () => isUndefined,
|
|
85
89
|
kebabCase: () => kebabCase,
|
|
86
90
|
keyBy: () => keyBy,
|
|
87
91
|
last: () => last,
|
|
88
92
|
lowerCase: () => lowerCase,
|
|
93
|
+
max: () => max,
|
|
89
94
|
maxBy: () => maxBy,
|
|
90
95
|
mean: () => mean,
|
|
91
96
|
meanBy: () => meanBy,
|
|
97
|
+
min: () => min,
|
|
92
98
|
minBy: () => minBy,
|
|
93
99
|
negate: () => negate,
|
|
94
100
|
noop: () => noop,
|
|
@@ -105,9 +111,11 @@ __export(src_exports, {
|
|
|
105
111
|
round: () => round,
|
|
106
112
|
sample: () => sample,
|
|
107
113
|
sampleSize: () => sampleSize,
|
|
114
|
+
set: () => set,
|
|
108
115
|
shuffle: () => shuffle,
|
|
109
116
|
snakeCase: () => snakeCase,
|
|
110
117
|
startCase: () => startCase,
|
|
118
|
+
startsWith: () => startsWith,
|
|
111
119
|
sum: () => sum,
|
|
112
120
|
sumBy: () => sumBy,
|
|
113
121
|
tail: () => tail,
|
|
@@ -132,6 +140,7 @@ __export(src_exports, {
|
|
|
132
140
|
xorWith: () => xorWith,
|
|
133
141
|
zip: () => zip,
|
|
134
142
|
zipObject: () => zipObject,
|
|
143
|
+
zipObjectDeep: () => zipObjectDeep,
|
|
135
144
|
zipWith: () => zipWith
|
|
136
145
|
});
|
|
137
146
|
|
|
@@ -324,11 +333,11 @@ function keyBy(arr, getKeyFromItem) {
|
|
|
324
333
|
// src/array/maxBy.ts
|
|
325
334
|
function maxBy(items, getValue) {
|
|
326
335
|
let maxElement = items[0];
|
|
327
|
-
let
|
|
336
|
+
let max2 = -Infinity;
|
|
328
337
|
for (const element of items) {
|
|
329
338
|
const value = getValue(element);
|
|
330
|
-
if (value >
|
|
331
|
-
|
|
339
|
+
if (value > max2) {
|
|
340
|
+
max2 = value;
|
|
332
341
|
maxElement = element;
|
|
333
342
|
}
|
|
334
343
|
}
|
|
@@ -338,11 +347,11 @@ function maxBy(items, getValue) {
|
|
|
338
347
|
// src/array/minBy.ts
|
|
339
348
|
function minBy(items, getValue) {
|
|
340
349
|
let minElement = items[0];
|
|
341
|
-
let
|
|
350
|
+
let min2 = Infinity;
|
|
342
351
|
for (const element of items) {
|
|
343
352
|
const value = getValue(element);
|
|
344
|
-
if (value <
|
|
345
|
-
|
|
353
|
+
if (value < min2) {
|
|
354
|
+
min2 = value;
|
|
346
355
|
minElement = element;
|
|
347
356
|
}
|
|
348
357
|
}
|
|
@@ -1103,6 +1112,214 @@ function startCase(str) {
|
|
|
1103
1112
|
return result;
|
|
1104
1113
|
}
|
|
1105
1114
|
|
|
1115
|
+
// src/compat/array/chunk.ts
|
|
1116
|
+
function chunk2(arr, size = 1) {
|
|
1117
|
+
size = Math.max(Math.floor(size), 0);
|
|
1118
|
+
if (size === 0) {
|
|
1119
|
+
return [];
|
|
1120
|
+
}
|
|
1121
|
+
return chunk(arr, size);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// src/compat/array/concat.ts
|
|
1125
|
+
function concat(...values) {
|
|
1126
|
+
return flatten(values);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// src/compat/array/difference.ts
|
|
1130
|
+
function difference2(arr, ...values) {
|
|
1131
|
+
const arr1 = arr;
|
|
1132
|
+
const arr2 = flatten(values);
|
|
1133
|
+
return difference(arr1, arr2);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// src/compat/_internal/isIndex.ts
|
|
1137
|
+
var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
1138
|
+
function isIndex(value) {
|
|
1139
|
+
switch (typeof value) {
|
|
1140
|
+
case "number": {
|
|
1141
|
+
return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;
|
|
1142
|
+
}
|
|
1143
|
+
case "symbol": {
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
case "string": {
|
|
1147
|
+
return IS_UNSIGNED_INTEGER.test(value);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// src/compat/_internal/toPath.ts
|
|
1153
|
+
function toPath(deepKey) {
|
|
1154
|
+
const ESCAPE_REGEXP = /\\(\\)?/g;
|
|
1155
|
+
const PROPERTY_REGEXP = RegExp(
|
|
1156
|
+
// Match anything that isn't a dot or bracket.
|
|
1157
|
+
`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
|
|
1158
|
+
"g"
|
|
1159
|
+
);
|
|
1160
|
+
const result = [];
|
|
1161
|
+
if (deepKey[0] === ".") {
|
|
1162
|
+
result.push("");
|
|
1163
|
+
}
|
|
1164
|
+
let match;
|
|
1165
|
+
let lastIndex = 0;
|
|
1166
|
+
let count = 0;
|
|
1167
|
+
while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
|
|
1168
|
+
let [key, expr, quote, substr] = match;
|
|
1169
|
+
if (quote) {
|
|
1170
|
+
key = substr.replace(ESCAPE_REGEXP, "$1");
|
|
1171
|
+
} else if (expr) {
|
|
1172
|
+
key = expr;
|
|
1173
|
+
}
|
|
1174
|
+
result.push(key);
|
|
1175
|
+
if (PROPERTY_REGEXP.lastIndex === lastIndex) {
|
|
1176
|
+
PROPERTY_REGEXP.lastIndex++;
|
|
1177
|
+
} else {
|
|
1178
|
+
lastIndex = PROPERTY_REGEXP.lastIndex;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
return result;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// src/compat/object/set.ts
|
|
1185
|
+
function set(obj, path, value) {
|
|
1186
|
+
const resolvedPath = Array.isArray(path) ? path : typeof path === "string" ? toPath(path) : [path];
|
|
1187
|
+
let current = obj;
|
|
1188
|
+
for (let i = 0; i < resolvedPath.length - 1; i++) {
|
|
1189
|
+
const key = resolvedPath[i];
|
|
1190
|
+
const nextKey = resolvedPath[i + 1];
|
|
1191
|
+
if (current[key] == null) {
|
|
1192
|
+
current[key] = isIndex(nextKey) ? [] : {};
|
|
1193
|
+
}
|
|
1194
|
+
current = current[key];
|
|
1195
|
+
}
|
|
1196
|
+
const lastKey = resolvedPath[resolvedPath.length - 1];
|
|
1197
|
+
current[lastKey] = value;
|
|
1198
|
+
return obj;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/compat/array/zipObjectDeep.ts
|
|
1202
|
+
function zipObjectDeep(keys, values) {
|
|
1203
|
+
const result = {};
|
|
1204
|
+
const zipped = zip(keys, values);
|
|
1205
|
+
for (let i = 0; i < zipped.length; i++) {
|
|
1206
|
+
const [key, value] = zipped[i];
|
|
1207
|
+
if (key != null) {
|
|
1208
|
+
set(result, key, value);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// src/compat/_internal/isDeepKey.ts
|
|
1215
|
+
var IS_PLAIN = /^\w*$/;
|
|
1216
|
+
var IS_DEEP = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
1217
|
+
function isDeepKey(key) {
|
|
1218
|
+
switch (typeof key) {
|
|
1219
|
+
case "number":
|
|
1220
|
+
case "symbol": {
|
|
1221
|
+
return false;
|
|
1222
|
+
}
|
|
1223
|
+
case "string": {
|
|
1224
|
+
return !IS_PLAIN.test(key) && IS_DEEP.test(key);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/compat/object/get.ts
|
|
1230
|
+
function get(object, path, defaultValue) {
|
|
1231
|
+
let resolvedPath;
|
|
1232
|
+
if (Array.isArray(path)) {
|
|
1233
|
+
resolvedPath = path;
|
|
1234
|
+
} else if (typeof path === "string" && isDeepKey(path) && (object == null ? void 0 : object[path]) == null) {
|
|
1235
|
+
resolvedPath = toPath(path);
|
|
1236
|
+
} else {
|
|
1237
|
+
resolvedPath = [path];
|
|
1238
|
+
}
|
|
1239
|
+
if (resolvedPath.length === 0) {
|
|
1240
|
+
return defaultValue;
|
|
1241
|
+
}
|
|
1242
|
+
let current = object;
|
|
1243
|
+
let index;
|
|
1244
|
+
for (index = 0; index < resolvedPath.length && current != null; index++) {
|
|
1245
|
+
let key = resolvedPath[index];
|
|
1246
|
+
if (Object.is(key.valueOf(), -0)) {
|
|
1247
|
+
key = "-0";
|
|
1248
|
+
}
|
|
1249
|
+
current = current[key];
|
|
1250
|
+
}
|
|
1251
|
+
if (current === null && index === resolvedPath.length) {
|
|
1252
|
+
return current;
|
|
1253
|
+
}
|
|
1254
|
+
return current != null ? current : defaultValue;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// src/compat/predicate/isPlainObject.ts
|
|
1258
|
+
function isPlainObject2(object) {
|
|
1259
|
+
var _a;
|
|
1260
|
+
if (typeof object !== "object") {
|
|
1261
|
+
return false;
|
|
1262
|
+
}
|
|
1263
|
+
if (object == null) {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
if (Object.getPrototypeOf(object) === null) {
|
|
1267
|
+
return true;
|
|
1268
|
+
}
|
|
1269
|
+
if (object.toString() !== "[object Object]") {
|
|
1270
|
+
const tag = object[Symbol.toStringTag];
|
|
1271
|
+
if (tag == null) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
const isTagReadonly = !((_a = Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)) == null ? void 0 : _a.writable);
|
|
1275
|
+
if (isTagReadonly) {
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1278
|
+
return object.toString() === `[object ${tag}]`;
|
|
1279
|
+
}
|
|
1280
|
+
let proto = object;
|
|
1281
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
1282
|
+
proto = Object.getPrototypeOf(proto);
|
|
1283
|
+
}
|
|
1284
|
+
return Object.getPrototypeOf(object) === proto;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/compat/string/startsWith.ts
|
|
1288
|
+
var startsWith = (str, target, position = 0) => {
|
|
1289
|
+
return str.startsWith(target, position);
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1292
|
+
// src/compat/string/endsWith.ts
|
|
1293
|
+
var endsWith = (str, target, position = str.length) => {
|
|
1294
|
+
return str.endsWith(target, position);
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
// src/compat/math/max.ts
|
|
1298
|
+
function max(items = []) {
|
|
1299
|
+
let maxElement = items[0];
|
|
1300
|
+
let max2 = void 0;
|
|
1301
|
+
for (const element of items) {
|
|
1302
|
+
if (max2 == null || element > max2) {
|
|
1303
|
+
max2 = element;
|
|
1304
|
+
maxElement = element;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return maxElement;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/compat/math/min.ts
|
|
1311
|
+
function min(items = []) {
|
|
1312
|
+
let minElement = items[0];
|
|
1313
|
+
let min2 = void 0;
|
|
1314
|
+
for (const element of items) {
|
|
1315
|
+
if (min2 == null || element < min2) {
|
|
1316
|
+
min2 = element;
|
|
1317
|
+
minElement = element;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
return minElement;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1106
1323
|
// src/browser.ts
|
|
1107
|
-
window._ =
|
|
1324
|
+
window._ = compat_exports;
|
|
1108
1325
|
//# sourceMappingURL=browser.js.map
|