es-toolkit 1.10.1-dev.229 → 1.10.1-dev.231

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.
Files changed (46) hide show
  1. package/dist/array/index.mjs +31 -31
  2. package/dist/chunk-54TK5BIS.mjs +1 -0
  3. package/dist/chunk-GL7PPRA4.mjs +25 -0
  4. package/dist/chunk-GL7PPRA4.mjs.map +1 -0
  5. package/dist/chunk-MJA7DAOJ.mjs +25 -0
  6. package/dist/chunk-MJA7DAOJ.mjs.map +1 -0
  7. package/dist/chunk-XT74R35S.mjs +1 -0
  8. package/dist/compat/index.d.mts +2 -0
  9. package/dist/compat/index.d.ts +2 -0
  10. package/dist/compat/index.js +42 -0
  11. package/dist/compat/index.js.map +1 -1
  12. package/dist/compat/index.mjs +66 -58
  13. package/dist/compat/index.mjs.map +1 -1
  14. package/dist/function/index.mjs +6 -6
  15. package/dist/index.d.mts +2 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.js +42 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +66 -58
  20. package/dist/object/index.d.mts +1 -0
  21. package/dist/object/index.d.ts +1 -0
  22. package/dist/object/index.js +25 -2
  23. package/dist/object/index.js.map +1 -1
  24. package/dist/object/index.mjs +6 -2
  25. package/dist/object/set.d.mts +32 -0
  26. package/dist/object/set.d.ts +32 -0
  27. package/dist/object/set.js +49 -0
  28. package/dist/object/set.js.map +1 -0
  29. package/dist/object/set.mjs +8 -0
  30. package/dist/object/set.mjs.map +1 -0
  31. package/dist/string/index.d.mts +1 -0
  32. package/dist/string/index.d.ts +1 -0
  33. package/dist/string/index.js +21 -2
  34. package/dist/string/index.js.map +1 -1
  35. package/dist/string/index.mjs +6 -2
  36. package/dist/string/startCase.d.mts +16 -0
  37. package/dist/string/startCase.d.ts +16 -0
  38. package/dist/string/startCase.js +54 -0
  39. package/dist/string/startCase.js.map +1 -0
  40. package/dist/string/startCase.mjs +9 -0
  41. package/dist/string/startCase.mjs.map +1 -0
  42. package/package.json +1 -1
  43. package/dist/chunk-OSOLEQLZ.mjs +0 -1
  44. package/dist/chunk-QKYYOLJ6.mjs +0 -1
  45. /package/dist/{chunk-OSOLEQLZ.mjs.map → chunk-54TK5BIS.mjs.map} +0 -0
  46. /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-XT74R35S.mjs.map} +0 -0
@@ -1,5 +1,6 @@
1
1
  import "../chunk-NKLIE2OI.mjs";
2
- import "../chunk-QKYYOLJ6.mjs";
2
+ import "../chunk-ARZ5BDR6.mjs";
3
+ import "../chunk-XT74R35S.mjs";
3
4
  import {
4
5
  camelCase
5
6
  } from "../chunk-Y5V7UAZZ.mjs";
@@ -15,6 +16,9 @@ import {
15
16
  import {
16
17
  snakeCase
17
18
  } from "../chunk-F3WCQQET.mjs";
19
+ import {
20
+ startCase
21
+ } from "../chunk-MJA7DAOJ.mjs";
18
22
  import "../chunk-WVQ7YVRK.mjs";
19
23
  import "../chunk-ASJF5D6C.mjs";
20
24
  import {
@@ -32,11 +36,13 @@ import {
32
36
  import {
33
37
  isUndefined
34
38
  } from "../chunk-VH2PV426.mjs";
35
- import "../chunk-ARZ5BDR6.mjs";
36
39
  import {
37
40
  delay
38
41
  } from "../chunk-O64NE2P4.mjs";
39
- import "../chunk-OSOLEQLZ.mjs";
42
+ import "../chunk-54TK5BIS.mjs";
43
+ import {
44
+ set
45
+ } from "../chunk-GL7PPRA4.mjs";
40
46
  import {
41
47
  clone
42
48
  } from "../chunk-U4JGKZ56.mjs";
@@ -74,22 +80,6 @@ import {
74
80
  import {
75
81
  sum
76
82
  } from "../chunk-2SLTL4KL.mjs";
77
- import "../chunk-236H5JZJ.mjs";
78
- import {
79
- debounce
80
- } from "../chunk-3IP4JVLL.mjs";
81
- import {
82
- negate
83
- } from "../chunk-BOOQBJN2.mjs";
84
- import {
85
- noop
86
- } from "../chunk-LKXCOLNY.mjs";
87
- import {
88
- once
89
- } from "../chunk-CMBC4MXG.mjs";
90
- import {
91
- throttle
92
- } from "../chunk-QOJGMVVR.mjs";
93
83
  import {
94
84
  clamp
95
85
  } from "../chunk-MLCL773E.mjs";
@@ -97,12 +87,6 @@ import {
97
87
  inRange
98
88
  } from "../chunk-BH6HLGBA.mjs";
99
89
  import "../chunk-DDH7K4QM.mjs";
100
- import {
101
- unzipWith
102
- } from "../chunk-IFNXROZR.mjs";
103
- import {
104
- without
105
- } from "../chunk-PYEYV7BY.mjs";
106
90
  import {
107
91
  xor
108
92
  } from "../chunk-L7FQX5MN.mjs";
@@ -121,21 +105,12 @@ import {
121
105
  import {
122
106
  zipWith
123
107
  } from "../chunk-4KYXHZ4R.mjs";
124
- import {
125
- toFilled
126
- } from "../chunk-OP4OAKQJ.mjs";
127
- import {
128
- union
129
- } from "../chunk-R6QA7PLZ.mjs";
130
108
  import {
131
109
  unionBy
132
110
  } from "../chunk-NFS7RWWE.mjs";
133
111
  import {
134
112
  unionWith
135
113
  } from "../chunk-2ZCITDMK.mjs";
136
- import {
137
- uniq
138
- } from "../chunk-DVK2N4KC.mjs";
139
114
  import {
140
115
  uniqBy
141
116
  } from "../chunk-OXAZEEGP.mjs";
@@ -146,17 +121,11 @@ import {
146
121
  unzip
147
122
  } from "../chunk-UYZKMBDO.mjs";
148
123
  import {
149
- sample
150
- } from "../chunk-2KNLZB7V.mjs";
151
- import {
152
- sampleSize
153
- } from "../chunk-EHSKB6DF.mjs";
154
- import {
155
- randomInt
156
- } from "../chunk-GIWAOOFY.mjs";
124
+ unzipWith
125
+ } from "../chunk-IFNXROZR.mjs";
157
126
  import {
158
- random
159
- } from "../chunk-SYWMYQYJ.mjs";
127
+ without
128
+ } from "../chunk-PYEYV7BY.mjs";
160
129
  import {
161
130
  shuffle
162
131
  } from "../chunk-G7UQ5PUR.mjs";
@@ -176,11 +145,14 @@ import {
176
145
  takeWhile
177
146
  } from "../chunk-2IXFGSUA.mjs";
178
147
  import {
179
- intersectionBy
180
- } from "../chunk-O6UXZR3U.mjs";
148
+ toFilled
149
+ } from "../chunk-OP4OAKQJ.mjs";
181
150
  import {
182
- intersectionWith
183
- } from "../chunk-XI7KRD2C.mjs";
151
+ union
152
+ } from "../chunk-R6QA7PLZ.mjs";
153
+ import {
154
+ uniq
155
+ } from "../chunk-DVK2N4KC.mjs";
184
156
  import {
185
157
  keyBy
186
158
  } from "../chunk-AJKZMN2V.mjs";
@@ -200,8 +172,17 @@ import {
200
172
  partition
201
173
  } from "../chunk-DN3NOZ3H.mjs";
202
174
  import {
203
- flattenDeep
204
- } from "../chunk-ML727RRJ.mjs";
175
+ sample
176
+ } from "../chunk-2KNLZB7V.mjs";
177
+ import {
178
+ sampleSize
179
+ } from "../chunk-EHSKB6DF.mjs";
180
+ import {
181
+ randomInt
182
+ } from "../chunk-GIWAOOFY.mjs";
183
+ import {
184
+ random
185
+ } from "../chunk-SYWMYQYJ.mjs";
205
186
  import {
206
187
  forEachRight
207
188
  } from "../chunk-IEA53J7P.mjs";
@@ -218,11 +199,11 @@ import {
218
199
  intersection
219
200
  } from "../chunk-FVVSE2F2.mjs";
220
201
  import {
221
- differenceBy
222
- } from "../chunk-LVWX5B43.mjs";
202
+ intersectionBy
203
+ } from "../chunk-O6UXZR3U.mjs";
223
204
  import {
224
- differenceWith
225
- } from "../chunk-6NVQAHXP.mjs";
205
+ intersectionWith
206
+ } from "../chunk-XI7KRD2C.mjs";
226
207
  import {
227
208
  drop
228
209
  } from "../chunk-S3CORED5.mjs";
@@ -241,13 +222,12 @@ import {
241
222
  import {
242
223
  flatMap
243
224
  } from "../chunk-KBXHURLW.mjs";
225
+ import {
226
+ flattenDeep
227
+ } from "../chunk-ML727RRJ.mjs";
244
228
  import {
245
229
  flatten
246
230
  } from "../chunk-33MSBDC6.mjs";
247
- import "../chunk-FZEZH22H.mjs";
248
- import {
249
- AbortError
250
- } from "../chunk-DXB7EZUQ.mjs";
251
231
  import {
252
232
  chunk
253
233
  } from "../chunk-E6C5EZQA.mjs";
@@ -260,6 +240,32 @@ import {
260
240
  import {
261
241
  difference
262
242
  } from "../chunk-JPUKH67K.mjs";
243
+ import {
244
+ differenceBy
245
+ } from "../chunk-LVWX5B43.mjs";
246
+ import {
247
+ differenceWith
248
+ } from "../chunk-6NVQAHXP.mjs";
249
+ import "../chunk-FZEZH22H.mjs";
250
+ import {
251
+ AbortError
252
+ } from "../chunk-DXB7EZUQ.mjs";
253
+ import "../chunk-236H5JZJ.mjs";
254
+ import {
255
+ once
256
+ } from "../chunk-CMBC4MXG.mjs";
257
+ import {
258
+ throttle
259
+ } from "../chunk-QOJGMVVR.mjs";
260
+ import {
261
+ debounce
262
+ } from "../chunk-3IP4JVLL.mjs";
263
+ import {
264
+ negate
265
+ } from "../chunk-BOOQBJN2.mjs";
266
+ import {
267
+ noop
268
+ } from "../chunk-LKXCOLNY.mjs";
263
269
  import "../chunk-2MM5EJJX.mjs";
264
270
 
265
271
  // src/compat/array/chunk.ts
@@ -329,8 +335,10 @@ export {
329
335
  round,
330
336
  sample,
331
337
  sampleSize,
338
+ set,
332
339
  shuffle,
333
340
  snakeCase,
341
+ startCase,
334
342
  sum,
335
343
  sumBy,
336
344
  tail,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAASA,OAAS,KAAmB,OAAe,GAAU;AACnE,SAAO,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC;AAEnC,MAAI,SAAS,GAAG;AACd,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAa,KAAK,IAAI;AAC/B;","names":["chunk"]}
1
+ {"version":3,"sources":["../../src/compat/array/chunk.ts"],"sourcesContent":["import { chunk as chunkToolkit } from '../../array/chunk.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0) {\n return [];\n }\n\n return chunkToolkit(arr, size);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAASA,OAAS,KAAmB,OAAe,GAAU;AACnE,SAAO,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC;AAEnC,MAAI,SAAS,GAAG;AACd,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAa,KAAK,IAAI;AAC/B;","names":["chunk"]}
@@ -1,4 +1,10 @@
1
1
  import "../chunk-236H5JZJ.mjs";
2
+ import {
3
+ once
4
+ } from "../chunk-CMBC4MXG.mjs";
5
+ import {
6
+ throttle
7
+ } from "../chunk-QOJGMVVR.mjs";
2
8
  import {
3
9
  debounce
4
10
  } from "../chunk-3IP4JVLL.mjs";
@@ -8,12 +14,6 @@ import {
8
14
  import {
9
15
  noop
10
16
  } from "../chunk-LKXCOLNY.mjs";
11
- import {
12
- once
13
- } from "../chunk-CMBC4MXG.mjs";
14
- import {
15
- throttle
16
- } from "../chunk-QOJGMVVR.mjs";
17
17
  import "../chunk-2MM5EJJX.mjs";
18
18
  export {
19
19
  debounce,
package/dist/index.d.mts CHANGED
@@ -71,6 +71,7 @@ export { pick } from './object/pick.mjs';
71
71
  export { pickBy } from './object/pickBy.mjs';
72
72
  export { invert } from './object/invert.mjs';
73
73
  export { clone } from './object/clone.mjs';
74
+ export { set } from './object/set.mjs';
74
75
  export { isEqual } from './predicate/isEqual.mjs';
75
76
  export { isNil } from './predicate/isNil.mjs';
76
77
  export { isNotNil } from './predicate/isNotNil.mjs';
@@ -81,4 +82,5 @@ export { camelCase } from './string/camelCase.mjs';
81
82
  export { snakeCase } from './string/snakeCase.mjs';
82
83
  export { kebabCase } from './string/kebabCase.mjs';
83
84
  export { lowerCase } from './string/lowerCase.mjs';
85
+ export { startCase } from './string/startCase.mjs';
84
86
  export { capitalize } from './string/capitalize.mjs';
package/dist/index.d.ts CHANGED
@@ -71,6 +71,7 @@ export { pick } from './object/pick.js';
71
71
  export { pickBy } from './object/pickBy.js';
72
72
  export { invert } from './object/invert.js';
73
73
  export { clone } from './object/clone.js';
74
+ export { set } from './object/set.js';
74
75
  export { isEqual } from './predicate/isEqual.js';
75
76
  export { isNil } from './predicate/isNil.js';
76
77
  export { isNotNil } from './predicate/isNotNil.js';
@@ -81,4 +82,5 @@ export { camelCase } from './string/camelCase.js';
81
82
  export { snakeCase } from './string/snakeCase.js';
82
83
  export { kebabCase } from './string/kebabCase.js';
83
84
  export { lowerCase } from './string/lowerCase.js';
85
+ export { startCase } from './string/startCase.js';
84
86
  export { capitalize } from './string/capitalize.js';
package/dist/index.js CHANGED
@@ -92,8 +92,10 @@ __export(src_exports, {
92
92
  round: () => round,
93
93
  sample: () => sample,
94
94
  sampleSize: () => sampleSize,
95
+ set: () => set,
95
96
  shuffle: () => shuffle,
96
97
  snakeCase: () => snakeCase,
98
+ startCase: () => startCase,
97
99
  sum: () => sum,
98
100
  sumBy: () => sumBy,
99
101
  tail: () => tail,
@@ -880,6 +882,27 @@ function isPrimitive(value) {
880
882
  return value == null || typeof value !== "object" && typeof value !== "function";
881
883
  }
882
884
 
885
+ // src/object/set.ts
886
+ function set(obj, path, value) {
887
+ if (obj instanceof Map || obj instanceof Set) {
888
+ throw new TypeError("Set or Map is not supported");
889
+ }
890
+ const keys = Array.isArray(path) ? path : String(path).replace(/\[|\]/g, (match) => {
891
+ return match === "[" ? "." : "";
892
+ }).split(".");
893
+ let pointer = obj;
894
+ for (let i = 0; i < keys.length - 1; i++) {
895
+ const key = keys[i];
896
+ const nextKey = keys[i + 1];
897
+ if (pointer[key] == null || typeof pointer[key] !== "object") {
898
+ pointer[key] = /^\d+$/.test(nextKey) ? [] : {};
899
+ }
900
+ pointer = pointer[key];
901
+ }
902
+ pointer[keys[keys.length - 1]] = value;
903
+ return obj;
904
+ }
905
+
883
906
  // src/predicate/isEqual.ts
884
907
  function isEqual(a, b) {
885
908
  if (Object.is(a, b)) {
@@ -990,6 +1013,23 @@ var lowerCase = (str) => {
990
1013
  const words = getWords(str);
991
1014
  return words.map((word) => word.toLowerCase()).join(" ");
992
1015
  };
1016
+
1017
+ // src/string/startCase.ts
1018
+ function startCase(str) {
1019
+ const words = getWords(str.trim());
1020
+ let result = "";
1021
+ for (const word of words) {
1022
+ if (result) {
1023
+ result += " ";
1024
+ }
1025
+ if (word === word.toUpperCase()) {
1026
+ result += word;
1027
+ } else {
1028
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
1029
+ }
1030
+ }
1031
+ return result;
1032
+ }
993
1033
  // Annotate the CommonJS export names for ESM import in node:
994
1034
  0 && (module.exports = {
995
1035
  AbortError,
@@ -1050,8 +1090,10 @@ var lowerCase = (str) => {
1050
1090
  round,
1051
1091
  sample,
1052
1092
  sampleSize,
1093
+ set,
1053
1094
  shuffle,
1054
1095
  snakeCase,
1096
+ startCase,
1055
1097
  sum,
1056
1098
  sumBy,
1057
1099
  tail,