es-toolkit 1.34.1 → 1.35.0-dev.1167

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 (120) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/_chunk/partialRight-B0_CSB.js +50 -0
  3. package/dist/_chunk/{upperFirst-nA5L7X.js → reverseString-D-wK2p.js} +26 -94
  4. package/dist/_chunk/snakeCase-BtVEeB.js +75 -0
  5. package/dist/_chunk/{toMerged-CwnQF6.js → toSnakeCaseKeys-BNpS71.js} +281 -32
  6. package/dist/_chunk/{unary-c1NFA5.js → unary-BsNWRM.js} +3 -50
  7. package/dist/_chunk/{zipWith-Bdyzuy.js → zip-_HttSl.js} +0 -35
  8. package/dist/array/index.js +90 -58
  9. package/dist/browser.global.js +1 -1
  10. package/dist/browser.global.js.map +1 -1
  11. package/dist/compat/_internal/getSymbolsIn.mjs +12 -0
  12. package/dist/compat/array/sortedIndexBy.d.mts +3 -2
  13. package/dist/compat/array/sortedIndexBy.d.ts +3 -2
  14. package/dist/compat/array/sortedIndexBy.mjs +5 -3
  15. package/dist/compat/array/sortedLastIndex.d.mts +16 -0
  16. package/dist/compat/array/sortedLastIndex.d.ts +16 -0
  17. package/dist/compat/array/sortedLastIndex.mjs +31 -0
  18. package/dist/compat/array/sortedLastIndexBy.d.mts +20 -0
  19. package/dist/compat/array/sortedLastIndexBy.d.ts +20 -0
  20. package/dist/compat/array/sortedLastIndexBy.mjs +7 -0
  21. package/dist/compat/array/takeWhile.d.mts +84 -0
  22. package/dist/compat/array/takeWhile.d.ts +84 -0
  23. package/dist/compat/array/takeWhile.mjs +15 -0
  24. package/dist/compat/array/unionBy.d.mts +25 -0
  25. package/dist/compat/array/unionBy.d.ts +25 -0
  26. package/dist/compat/array/unionBy.mjs +17 -0
  27. package/dist/compat/array/unionWith.d.mts +31 -0
  28. package/dist/compat/array/unionWith.d.ts +31 -0
  29. package/dist/compat/array/unionWith.mjs +16 -0
  30. package/dist/compat/array/uniqWith.d.mts +27 -0
  31. package/dist/compat/array/uniqWith.d.ts +27 -0
  32. package/dist/compat/array/uniqWith.mjs +12 -0
  33. package/dist/compat/array/unzip.mjs +4 -4
  34. package/dist/compat/array/zipObject.d.mts +49 -0
  35. package/dist/compat/array/zipObject.d.ts +49 -0
  36. package/dist/compat/array/zipObject.mjs +11 -0
  37. package/dist/compat/array/zipWith.d.mts +92 -0
  38. package/dist/compat/array/zipWith.d.ts +92 -0
  39. package/dist/compat/array/zipWith.mjs +20 -0
  40. package/dist/compat/index.d.mts +23 -7
  41. package/dist/compat/index.d.ts +23 -7
  42. package/dist/compat/index.js +553 -444
  43. package/dist/compat/index.mjs +23 -7
  44. package/dist/compat/object/assign.d.mts +103 -0
  45. package/dist/compat/object/assign.d.ts +103 -0
  46. package/dist/compat/object/assign.mjs +20 -0
  47. package/dist/compat/object/assignInWith.d.mts +160 -0
  48. package/dist/compat/object/assignInWith.d.ts +160 -0
  49. package/dist/compat/object/assignInWith.mjs +30 -0
  50. package/dist/compat/object/assignWith.d.mts +160 -0
  51. package/dist/compat/object/assignWith.d.ts +160 -0
  52. package/dist/compat/object/assignWith.mjs +30 -0
  53. package/dist/compat/object/at.d.mts +19 -0
  54. package/dist/compat/object/at.d.ts +19 -0
  55. package/dist/compat/object/at.mjs +27 -0
  56. package/dist/compat/object/create.d.mts +16 -0
  57. package/dist/compat/object/create.d.ts +16 -0
  58. package/dist/compat/object/create.mjs +18 -0
  59. package/dist/compat/object/functions.d.mts +24 -0
  60. package/dist/compat/object/functions.d.ts +24 -0
  61. package/dist/compat/object/functions.mjs +10 -0
  62. package/dist/compat/object/pick.mjs +7 -1
  63. package/dist/compat/object/pickBy.mjs +5 -2
  64. package/dist/compat/object/set.d.mts +2 -2
  65. package/dist/compat/object/set.d.ts +2 -2
  66. package/dist/compat/object/set.mjs +2 -28
  67. package/dist/compat/object/toPairs.d.mts +34 -0
  68. package/dist/compat/object/toPairs.d.ts +34 -0
  69. package/dist/compat/object/toPairs.mjs +17 -0
  70. package/dist/compat/object/toPairsIn.d.mts +34 -0
  71. package/dist/compat/object/toPairsIn.d.ts +34 -0
  72. package/dist/compat/object/toPairsIn.mjs +17 -0
  73. package/dist/compat/object/update.d.mts +13 -0
  74. package/dist/compat/object/update.d.ts +13 -0
  75. package/dist/compat/object/update.mjs +7 -0
  76. package/dist/compat/object/updateWith.d.mts +14 -0
  77. package/dist/compat/object/updateWith.d.ts +14 -0
  78. package/dist/compat/object/updateWith.mjs +44 -0
  79. package/dist/compat/predicate/isPlainObject.d.mts +1 -1
  80. package/dist/compat/predicate/isPlainObject.d.ts +1 -1
  81. package/dist/compat/string/split.d.mts +19 -0
  82. package/dist/compat/string/split.d.ts +19 -0
  83. package/dist/compat/string/split.mjs +7 -0
  84. package/dist/compat/util/cond.d.mts +30 -0
  85. package/dist/compat/util/cond.d.ts +30 -0
  86. package/dist/compat/util/cond.mjs +26 -0
  87. package/dist/compat/util/iteratee.d.mts +2 -2
  88. package/dist/compat/util/iteratee.d.ts +2 -2
  89. package/dist/compat/util/over.d.mts +32 -0
  90. package/dist/compat/util/over.d.ts +32 -0
  91. package/dist/compat/util/over.mjs +13 -0
  92. package/dist/function/index.js +4 -3
  93. package/dist/function/retry.d.mts +21 -3
  94. package/dist/function/retry.d.ts +21 -3
  95. package/dist/function/retry.mjs +3 -2
  96. package/dist/index.d.mts +2 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.js +125 -121
  99. package/dist/index.mjs +2 -0
  100. package/dist/object/index.d.mts +2 -0
  101. package/dist/object/index.d.ts +2 -0
  102. package/dist/object/index.js +15 -13
  103. package/dist/object/index.mjs +2 -0
  104. package/dist/object/toCamelCaseKeys.d.mts +53 -0
  105. package/dist/object/toCamelCaseKeys.d.ts +53 -0
  106. package/dist/object/toCamelCaseKeys.mjs +30 -0
  107. package/dist/object/toSnakeCaseKeys.d.mts +53 -0
  108. package/dist/object/toSnakeCaseKeys.d.ts +53 -0
  109. package/dist/object/toSnakeCaseKeys.mjs +30 -0
  110. package/dist/predicate/index.js +27 -27
  111. package/dist/predicate/isNode.d.mts +1 -1
  112. package/dist/predicate/isNode.d.ts +1 -1
  113. package/dist/string/index.js +23 -22
  114. package/dist/string/trimEnd.d.mts +3 -0
  115. package/dist/string/trimEnd.d.ts +3 -0
  116. package/dist/string/trimEnd.mjs +3 -0
  117. package/dist/string/trimStart.d.mts +3 -0
  118. package/dist/string/trimStart.d.ts +3 -0
  119. package/package.json +2 -1
  120. package/dist/_chunk/{isWeakSet-C2NpfO.js → isPromise-ByAybB.js} +57 -57
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # es-toolkit Changelog
2
2
 
3
+ ## Version v1.35.0
4
+
5
+ Released on April 16th, 2025.
6
+
7
+ - Added support for [toCamelCaseKeys](https://es-toolkit.slash.page/reference/object/toCamelCaseKeys.html) and [toSnakeCaseKeys](https://es-toolkit.slash.page/reference/object/toSnakeCaseKeys.html).
8
+ - Added support for custom delay function based on attempts in [retry](https://es-toolkit.slash.page/reference/function/retry.html).
9
+ - Introduced compatibility functions for [at](https://es-toolkit.slash.page/reference/array/at.html) (array), [split](https://es-toolkit.slash.page/reference/compat/string/split.html), [shuffle](https://es-toolkit.slash.page/reference/array/shuffle.html), [zipWith](https://es-toolkit.slash.page/reference/array/zipWith.html), [zipObject](https://es-toolkit.slash.page/reference/array/zipObject.html), [keyBy](https://es-toolkit.slash.page/reference/array/keyBy.html), [assign](https://es-toolkit.slash.page/reference/compat/object/assign.html), [assignInWith](https://es-toolkit.slash.page/reference/compat/object/assignInWith.html), [assignWith](https://es-toolkit.slash.page/reference/compat/object/assignWith.html), [update](https://es-toolkit.slash.page/reference/compat/object/update.html), [updateWith](https://es-toolkit.slash.page/reference/compat/object/updateWith.html), [uniqWith](https://es-toolkit.slash.page/reference/array/uniqWith.html), [unionBy](https://es-toolkit.slash.page/reference/array/unionBy.html), [unionWith](https://es-toolkit.slash.page/reference/array/unionWith.html), [takeWhile](https://es-toolkit.slash.page/reference/array/takeWhile.html), [sortedLastIndex](https://es-toolkit.slash.page/reference/compat/array/sortedLastIndex.html), [sortedLastIndexBy](https://es-toolkit.slash.page/reference/compat/array/sortedLastIndexBy.html), [toPairs](https://es-toolkit.slash.page/reference/compat/object/toPairs.html), [toPairsIn](https://es-toolkit.slash.page/reference/compat/object/toPairsIn.html), [cond](https://es-toolkit.slash.page/reference/compat/util/cond.html), [over](https://es-toolkit.slash.page/reference/compat/util/over.html), [functions](https://es-toolkit.slash.page/reference/compat/object/functions.html), and [create](https://es-toolkit.slash.page/reference/compat/object/create.html) in `es-toolkit/compat`.
10
+ - Fixed Lodash compatibility issues in [pick](https://es-toolkit.slash.page/reference/object/pick.html) and [pickBy](https://es-toolkit.slash.page/reference/object/pickBy.html).
11
+
12
+ We sincerely thank @shren207, @kim-sung-jee, @HyeokjaeLee, @Jeong-Rae, @D-Sketon, @jsparkdev, @wojtekmaj, @FengBuPi, @oror-sine, @L2HYUNN, @gs18004, @ohprettyhak, and @kimpuro for their contributions. We appreciate your great efforts!
13
+
3
14
  ## Version v1.34.1
4
15
 
5
16
  Released on March 27th, 2025.
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ function partial(func, ...partialArgs) {
4
+ return function (...providedArgs) {
5
+ const args = [];
6
+ let startIndex = 0;
7
+ for (let i = 0; i < partialArgs.length; i++) {
8
+ const arg = partialArgs[i];
9
+ if (arg === partial.placeholder) {
10
+ args.push(providedArgs[startIndex++]);
11
+ }
12
+ else {
13
+ args.push(arg);
14
+ }
15
+ }
16
+ for (let i = startIndex; i < providedArgs.length; i++) {
17
+ args.push(providedArgs[i]);
18
+ }
19
+ return func.apply(this, args);
20
+ };
21
+ }
22
+ const partialPlaceholder = Symbol('partial.placeholder');
23
+ partial.placeholder = partialPlaceholder;
24
+
25
+ function partialRight(func, ...partialArgs) {
26
+ return function (...providedArgs) {
27
+ const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
28
+ const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
29
+ const args = [];
30
+ let providedIndex = 0;
31
+ for (let i = 0; i < rangeLength; i++) {
32
+ args.push(providedArgs[providedIndex++]);
33
+ }
34
+ for (let i = 0; i < partialArgs.length; i++) {
35
+ const arg = partialArgs[i];
36
+ if (arg === partialRight.placeholder) {
37
+ args.push(providedArgs[providedIndex++]);
38
+ }
39
+ else {
40
+ args.push(arg);
41
+ }
42
+ }
43
+ return func.apply(this, args);
44
+ };
45
+ }
46
+ const partialRightPlaceholder = Symbol('partialRight.placeholder');
47
+ partialRight.placeholder = partialRightPlaceholder;
48
+
49
+ exports.partial = partial;
50
+ exports.partialRight = partialRight;
@@ -1,71 +1,6 @@
1
1
  'use strict';
2
2
 
3
- function capitalize(str) {
4
- return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
5
- }
6
-
7
- const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
8
- function words(str) {
9
- return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
10
- }
11
-
12
- function camelCase(str) {
13
- const words$1 = words(str);
14
- if (words$1.length === 0) {
15
- return '';
16
- }
17
- const [first, ...rest] = words$1;
18
- return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
19
- }
20
-
21
- function constantCase(str) {
22
- const words$1 = words(str);
23
- return words$1.map(word => word.toUpperCase()).join('_');
24
- }
25
-
26
- const deburrMap = new Map(Object.entries({
27
- Æ: 'Ae',
28
- Ð: 'D',
29
- Ø: 'O',
30
- Þ: 'Th',
31
- ß: 'ss',
32
- æ: 'ae',
33
- ð: 'd',
34
- ø: 'o',
35
- þ: 'th',
36
- Đ: 'D',
37
- đ: 'd',
38
- Ħ: 'H',
39
- ħ: 'h',
40
- ı: 'i',
41
- IJ: 'IJ',
42
- ij: 'ij',
43
- ĸ: 'k',
44
- Ŀ: 'L',
45
- ŀ: 'l',
46
- Ł: 'L',
47
- ł: 'l',
48
- ʼn: "'n",
49
- Ŋ: 'N',
50
- ŋ: 'n',
51
- Œ: 'Oe',
52
- œ: 'oe',
53
- Ŧ: 'T',
54
- ŧ: 't',
55
- ſ: 's',
56
- }));
57
- function deburr(str) {
58
- str = str.normalize('NFD');
59
- let result = '';
60
- for (let i = 0; i < str.length; i++) {
61
- const char = str[i];
62
- if ((char >= '\u0300' && char <= '\u036f') || (char >= '\ufe20' && char <= '\ufe23')) {
63
- continue;
64
- }
65
- result += deburrMap.get(char) ?? char;
66
- }
67
- return result;
68
- }
3
+ const snakeCase = require('./snakeCase-BtVEeB.js');
69
4
 
70
5
  const htmlEscapes = {
71
6
  '&': '&amp;',
@@ -83,13 +18,13 @@ function escapeRegExp(str) {
83
18
  }
84
19
 
85
20
  function kebabCase(str) {
86
- const words$1 = words(str);
87
- return words$1.map(word => word.toLowerCase()).join('-');
21
+ const words = snakeCase.words(str);
22
+ return words.map(word => word.toLowerCase()).join('-');
88
23
  }
89
24
 
90
25
  function lowerCase(str) {
91
- const words$1 = words(str);
92
- return words$1.map(word => word.toLowerCase()).join(' ');
26
+ const words = snakeCase.words(str);
27
+ return words.map(word => word.toLowerCase()).join(' ');
93
28
  }
94
29
 
95
30
  function lowerFirst(str) {
@@ -100,20 +35,6 @@ function pad(str, length, chars = ' ') {
100
35
  return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
101
36
  }
102
37
 
103
- function pascalCase(str) {
104
- const words$1 = words(str);
105
- return words$1.map(word => capitalize(word)).join('');
106
- }
107
-
108
- function reverseString(value) {
109
- return [...value].reverse().join('');
110
- }
111
-
112
- function snakeCase(str) {
113
- const words$1 = words(str);
114
- return words$1.map(word => word.toLowerCase()).join('_');
115
- }
116
-
117
38
  function trimEnd(str, chars) {
118
39
  if (chars === undefined) {
119
40
  return str.trimEnd();
@@ -121,6 +42,9 @@ function trimEnd(str, chars) {
121
42
  let endIndex = str.length;
122
43
  switch (typeof chars) {
123
44
  case 'string': {
45
+ if (chars.length !== 1) {
46
+ throw new Error(`The 'chars' parameter should be a single character string.`);
47
+ }
124
48
  while (endIndex > 0 && str[endIndex - 1] === chars) {
125
49
  endIndex--;
126
50
  }
@@ -175,11 +99,11 @@ function unescape(str) {
175
99
  }
176
100
 
177
101
  function upperCase(str) {
178
- const words$1 = words(str);
102
+ const words = snakeCase.words(str);
179
103
  let result = '';
180
- for (let i = 0; i < words$1.length; i++) {
181
- result += words$1[i].toUpperCase();
182
- if (i < words$1.length - 1) {
104
+ for (let i = 0; i < words.length; i++) {
105
+ result += words[i].toUpperCase();
106
+ if (i < words.length - 1) {
183
107
  result += ' ';
184
108
  }
185
109
  }
@@ -190,11 +114,21 @@ function upperFirst(str) {
190
114
  return str.substring(0, 1).toUpperCase() + str.substring(1);
191
115
  }
192
116
 
193
- exports.CASE_SPLIT_PATTERN = CASE_SPLIT_PATTERN;
194
- exports.camelCase = camelCase;
195
- exports.capitalize = capitalize;
117
+ function constantCase(str) {
118
+ const words = snakeCase.words(str);
119
+ return words.map(word => word.toUpperCase()).join('_');
120
+ }
121
+
122
+ function pascalCase(str) {
123
+ const words = snakeCase.words(str);
124
+ return words.map(word => snakeCase.capitalize(word)).join('');
125
+ }
126
+
127
+ function reverseString(value) {
128
+ return [...value].reverse().join('');
129
+ }
130
+
196
131
  exports.constantCase = constantCase;
197
- exports.deburr = deburr;
198
132
  exports.escape = escape;
199
133
  exports.escapeRegExp = escapeRegExp;
200
134
  exports.kebabCase = kebabCase;
@@ -203,11 +137,9 @@ exports.lowerFirst = lowerFirst;
203
137
  exports.pad = pad;
204
138
  exports.pascalCase = pascalCase;
205
139
  exports.reverseString = reverseString;
206
- exports.snakeCase = snakeCase;
207
140
  exports.trim = trim;
208
141
  exports.trimEnd = trimEnd;
209
142
  exports.trimStart = trimStart;
210
143
  exports.unescape = unescape;
211
144
  exports.upperCase = upperCase;
212
145
  exports.upperFirst = upperFirst;
213
- exports.words = words;
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ function capitalize(str) {
4
+ return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
5
+ }
6
+
7
+ const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
8
+ function words(str) {
9
+ return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
10
+ }
11
+
12
+ function camelCase(str) {
13
+ const words$1 = words(str);
14
+ if (words$1.length === 0) {
15
+ return '';
16
+ }
17
+ const [first, ...rest] = words$1;
18
+ return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
19
+ }
20
+
21
+ const deburrMap = new Map(Object.entries({
22
+ Æ: 'Ae',
23
+ Ð: 'D',
24
+ Ø: 'O',
25
+ Þ: 'Th',
26
+ ß: 'ss',
27
+ æ: 'ae',
28
+ ð: 'd',
29
+ ø: 'o',
30
+ þ: 'th',
31
+ Đ: 'D',
32
+ đ: 'd',
33
+ Ħ: 'H',
34
+ ħ: 'h',
35
+ ı: 'i',
36
+ IJ: 'IJ',
37
+ ij: 'ij',
38
+ ĸ: 'k',
39
+ Ŀ: 'L',
40
+ ŀ: 'l',
41
+ Ł: 'L',
42
+ ł: 'l',
43
+ ʼn: "'n",
44
+ Ŋ: 'N',
45
+ ŋ: 'n',
46
+ Œ: 'Oe',
47
+ œ: 'oe',
48
+ Ŧ: 'T',
49
+ ŧ: 't',
50
+ ſ: 's',
51
+ }));
52
+ function deburr(str) {
53
+ str = str.normalize('NFD');
54
+ let result = '';
55
+ for (let i = 0; i < str.length; i++) {
56
+ const char = str[i];
57
+ if ((char >= '\u0300' && char <= '\u036f') || (char >= '\ufe20' && char <= '\ufe23')) {
58
+ continue;
59
+ }
60
+ result += deburrMap.get(char) ?? char;
61
+ }
62
+ return result;
63
+ }
64
+
65
+ function snakeCase(str) {
66
+ const words$1 = words(str);
67
+ return words$1.map(word => word.toLowerCase()).join('_');
68
+ }
69
+
70
+ exports.CASE_SPLIT_PATTERN = CASE_SPLIT_PATTERN;
71
+ exports.camelCase = camelCase;
72
+ exports.capitalize = capitalize;
73
+ exports.deburr = deburr;
74
+ exports.snakeCase = snakeCase;
75
+ exports.words = words;