es-toolkit 1.13.0-dev.293 → 1.13.0-dev.294

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.
@@ -1,13 +1,4 @@
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";
11
2
  import {
12
3
  unzipWith
13
4
  } from "../chunk-IFNXROZR.mjs";
@@ -27,11 +18,11 @@ import {
27
18
  zip
28
19
  } from "../chunk-IDCUZVJL.mjs";
29
20
  import {
30
- takeRightWhile
31
- } from "../chunk-NTLX2MPV.mjs";
21
+ zipObject
22
+ } from "../chunk-6GWEY5EL.mjs";
32
23
  import {
33
- takeWhile
34
- } from "../chunk-2IXFGSUA.mjs";
24
+ zipWith
25
+ } from "../chunk-4KYXHZ4R.mjs";
35
26
  import {
36
27
  toFilled
37
28
  } from "../chunk-OP4OAKQJ.mjs";
@@ -44,9 +35,6 @@ import {
44
35
  import {
45
36
  unionWith
46
37
  } from "../chunk-2ZCITDMK.mjs";
47
- import {
48
- uniqWith
49
- } from "../chunk-237HGSZS.mjs";
50
38
  import {
51
39
  uniq
52
40
  } from "../chunk-DVK2N4KC.mjs";
@@ -54,11 +42,11 @@ import {
54
42
  uniqBy
55
43
  } from "../chunk-B4COTK4K.mjs";
56
44
  import {
57
- orderBy
58
- } from "../chunk-7B7W36UP.mjs";
45
+ uniqWith
46
+ } from "../chunk-237HGSZS.mjs";
59
47
  import {
60
- partition
61
- } from "../chunk-DN3NOZ3H.mjs";
48
+ unzip
49
+ } from "../chunk-UYZKMBDO.mjs";
62
50
  import {
63
51
  sample
64
52
  } from "../chunk-2KNLZB7V.mjs";
@@ -80,11 +68,11 @@ import {
80
68
  takeRight
81
69
  } from "../chunk-IQLKIDXF.mjs";
82
70
  import {
83
- initial
84
- } from "../chunk-XPSOKBRZ.mjs";
71
+ takeRightWhile
72
+ } from "../chunk-NTLX2MPV.mjs";
85
73
  import {
86
- intersection
87
- } from "../chunk-FVVSE2F2.mjs";
74
+ takeWhile
75
+ } from "../chunk-2IXFGSUA.mjs";
88
76
  import {
89
77
  intersectionBy
90
78
  } from "../chunk-O6UXZR3U.mjs";
@@ -104,17 +92,14 @@ import {
104
92
  minBy
105
93
  } from "../chunk-IJD7FE2Z.mjs";
106
94
  import {
107
- fill
108
- } from "../chunk-YFN6KOC4.mjs";
95
+ orderBy
96
+ } from "../chunk-7B7W36UP.mjs";
109
97
  import {
110
- flatMap
111
- } from "../chunk-UY76KTPE.mjs";
98
+ partition
99
+ } from "../chunk-DN3NOZ3H.mjs";
112
100
  import {
113
101
  flattenDeep
114
102
  } from "../chunk-ML727RRJ.mjs";
115
- import {
116
- flatten
117
- } from "../chunk-33MSBDC6.mjs";
118
103
  import {
119
104
  forEachRight
120
105
  } from "../chunk-IEA53J7P.mjs";
@@ -125,11 +110,11 @@ import {
125
110
  head
126
111
  } from "../chunk-HM2JT2RX.mjs";
127
112
  import {
128
- countBy
129
- } from "../chunk-CRSKT4WW.mjs";
113
+ initial
114
+ } from "../chunk-XPSOKBRZ.mjs";
130
115
  import {
131
- difference
132
- } from "../chunk-JPUKH67K.mjs";
116
+ intersection
117
+ } from "../chunk-FVVSE2F2.mjs";
133
118
  import {
134
119
  differenceBy
135
120
  } from "../chunk-LVWX5B43.mjs";
@@ -148,12 +133,27 @@ import {
148
133
  import {
149
134
  dropWhile
150
135
  } 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";
151
145
  import {
152
146
  chunk
153
147
  } from "../chunk-E6C5EZQA.mjs";
154
148
  import {
155
149
  compact
156
150
  } 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 src_exports = {};
45
- __export(src_exports, {
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: () => 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: () => 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: () => 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 max = -Infinity;
336
+ let max2 = -Infinity;
328
337
  for (const element of items) {
329
338
  const value = getValue(element);
330
- if (value > max) {
331
- max = value;
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 min = Infinity;
350
+ let min2 = Infinity;
342
351
  for (const element of items) {
343
352
  const value = getValue(element);
344
- if (value < min) {
345
- min = value;
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._ = src_exports;
1324
+ window._ = compat_exports;
1108
1325
  //# sourceMappingURL=browser.js.map