es-toolkit 1.23.0 → 1.24.0-dev.766

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 (135) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/dist/_chunk/{isWeakSet-BAMm2l.js → isWeakSet-Bd6nry.js} +59 -46
  4. package/dist/_chunk/{range-BXlMmn.js → sumBy-BkErWJ.js} +25 -5
  5. package/dist/_chunk/{isObjectLike-aywuSF.js → toMerged-DDLv0D.js} +88 -86
  6. package/dist/_chunk/{flowRight-Dv8J0U.js → unary-BZ5Ixo.js} +27 -64
  7. package/dist/_chunk/{zipWith-EOU_KZ.js → zipWith-wpjySR.js} +8 -17
  8. package/dist/array/dropRightWhile.d.mts +2 -2
  9. package/dist/array/dropRightWhile.d.ts +2 -2
  10. package/dist/array/dropRightWhile.mjs +1 -1
  11. package/dist/array/dropWhile.d.mts +1 -1
  12. package/dist/array/dropWhile.d.ts +1 -1
  13. package/dist/array/index.js +1 -1
  14. package/dist/array/unionBy.mjs +3 -10
  15. package/dist/browser.global.js +1 -1
  16. package/dist/browser.global.js.map +1 -1
  17. package/dist/compat/_internal/MAX_ARRAY_LENGTH.mjs +3 -0
  18. package/dist/compat/_internal/isIterateeCall.mjs +17 -0
  19. package/dist/compat/array/difference.d.mts +9 -3
  20. package/dist/compat/array/difference.d.ts +9 -3
  21. package/dist/compat/array/difference.mjs +12 -3
  22. package/dist/compat/array/dropRightWhile.d.mts +60 -0
  23. package/dist/compat/array/dropRightWhile.d.ts +60 -0
  24. package/dist/compat/array/dropRightWhile.mjs +27 -0
  25. package/dist/compat/array/every.mjs +4 -5
  26. package/dist/compat/array/filter.mjs +4 -5
  27. package/dist/compat/array/find.mjs +4 -5
  28. package/dist/compat/array/includes.mjs +2 -1
  29. package/dist/compat/array/slice.d.mts +18 -0
  30. package/dist/compat/array/slice.d.ts +18 -0
  31. package/dist/compat/array/slice.mjs +38 -0
  32. package/dist/compat/array/take.d.mts +25 -0
  33. package/dist/compat/array/take.d.ts +25 -0
  34. package/dist/compat/array/take.mjs +10 -0
  35. package/dist/compat/function/before.d.mts +26 -0
  36. package/dist/compat/function/before.d.ts +26 -0
  37. package/dist/compat/function/before.mjs +20 -0
  38. package/dist/compat/function/curryRight.d.mts +50 -0
  39. package/dist/compat/function/curryRight.d.ts +50 -0
  40. package/dist/compat/function/curryRight.mjs +64 -0
  41. package/dist/compat/index.d.mts +86 -75
  42. package/dist/compat/index.d.ts +86 -75
  43. package/dist/compat/index.js +779 -496
  44. package/dist/compat/index.mjs +86 -75
  45. package/dist/compat/object/defaults.d.mts +120 -0
  46. package/dist/compat/object/defaults.d.ts +120 -0
  47. package/dist/compat/object/defaults.mjs +21 -0
  48. package/dist/compat/object/invertBy.d.mts +27 -0
  49. package/dist/compat/object/invertBy.d.ts +27 -0
  50. package/dist/compat/object/invertBy.mjs +27 -0
  51. package/dist/compat/object/omit.d.mts +1 -1
  52. package/dist/compat/object/omit.d.ts +1 -1
  53. package/dist/compat/object/pick.d.mts +1 -1
  54. package/dist/compat/object/pick.d.ts +1 -1
  55. package/dist/compat/object/toDefaulted.d.mts +122 -0
  56. package/dist/compat/object/toDefaulted.d.ts +122 -0
  57. package/dist/compat/object/toDefaulted.mjs +9 -0
  58. package/dist/compat/predicate/isArrayBuffer.d.mts +20 -0
  59. package/dist/compat/predicate/isArrayBuffer.d.ts +20 -0
  60. package/dist/compat/predicate/isArrayBuffer.mjs +7 -0
  61. package/dist/compat/predicate/isDate.d.mts +16 -0
  62. package/dist/compat/predicate/isDate.d.ts +16 -0
  63. package/dist/compat/predicate/isDate.mjs +7 -0
  64. package/dist/compat/predicate/isEqualWith.d.mts +38 -0
  65. package/dist/compat/predicate/isEqualWith.d.ts +38 -0
  66. package/dist/compat/predicate/isEqualWith.mjs +23 -0
  67. package/dist/compat/predicate/isMap.d.mts +20 -0
  68. package/dist/compat/predicate/isMap.d.ts +20 -0
  69. package/dist/compat/predicate/isMap.mjs +7 -0
  70. package/dist/compat/predicate/isMatch.mjs +2 -1
  71. package/dist/compat/predicate/isSet.d.mts +20 -0
  72. package/dist/compat/predicate/isSet.d.ts +20 -0
  73. package/dist/compat/predicate/isSet.mjs +7 -0
  74. package/dist/compat/string/upperCase.mjs +0 -1
  75. package/dist/compat/util/constant.d.mts +16 -0
  76. package/dist/compat/util/constant.d.ts +16 -0
  77. package/dist/compat/util/constant.mjs +5 -0
  78. package/dist/compat/util/defaultTo.d.mts +17 -0
  79. package/dist/compat/util/defaultTo.d.ts +17 -0
  80. package/dist/compat/util/defaultTo.mjs +8 -0
  81. package/dist/compat/util/eq.d.mts +16 -0
  82. package/dist/compat/util/eq.d.ts +16 -0
  83. package/dist/compat/util/eq.mjs +5 -0
  84. package/dist/compat/util/times.d.mts +14 -0
  85. package/dist/compat/util/times.d.ts +14 -0
  86. package/dist/compat/util/times.mjs +15 -0
  87. package/dist/compat/util/toLength.d.mts +18 -0
  88. package/dist/compat/util/toLength.d.ts +18 -0
  89. package/dist/compat/util/toLength.mjs +12 -0
  90. package/dist/function/before.d.mts +2 -2
  91. package/dist/function/before.d.ts +2 -2
  92. package/dist/function/before.mjs +2 -2
  93. package/dist/function/index.d.mts +10 -10
  94. package/dist/function/index.d.ts +10 -10
  95. package/dist/function/index.js +65 -32
  96. package/dist/function/index.mjs +10 -10
  97. package/dist/function/once.d.mts +16 -1
  98. package/dist/function/once.d.ts +16 -1
  99. package/dist/function/once.mjs +5 -7
  100. package/dist/index.d.mts +43 -41
  101. package/dist/index.d.ts +43 -41
  102. package/dist/index.js +59 -57
  103. package/dist/index.mjs +43 -41
  104. package/dist/math/index.d.mts +2 -1
  105. package/dist/math/index.d.ts +2 -1
  106. package/dist/math/index.js +9 -8
  107. package/dist/math/index.mjs +2 -1
  108. package/dist/math/rangeRight.d.mts +38 -0
  109. package/dist/math/rangeRight.d.ts +38 -0
  110. package/dist/math/rangeRight.mjs +20 -0
  111. package/dist/object/index.d.mts +7 -7
  112. package/dist/object/index.d.ts +7 -7
  113. package/dist/object/index.js +32 -32
  114. package/dist/object/index.mjs +7 -7
  115. package/dist/object/omitBy.d.mts +1 -1
  116. package/dist/object/omitBy.d.ts +1 -1
  117. package/dist/object/omitBy.mjs +4 -3
  118. package/dist/object/pickBy.mjs +4 -3
  119. package/dist/predicate/index.d.mts +11 -10
  120. package/dist/predicate/index.d.ts +11 -10
  121. package/dist/predicate/index.js +8 -7
  122. package/dist/predicate/index.mjs +11 -10
  123. package/dist/predicate/isBlob.d.mts +19 -0
  124. package/dist/predicate/isBlob.d.ts +19 -0
  125. package/dist/predicate/isBlob.mjs +8 -0
  126. package/dist/predicate/isEqualWith.mjs +2 -1
  127. package/dist/promise/index.d.mts +1 -1
  128. package/dist/promise/index.d.ts +1 -1
  129. package/dist/promise/index.mjs +1 -1
  130. package/dist/string/index.d.mts +12 -12
  131. package/dist/string/index.d.ts +12 -12
  132. package/dist/string/index.js +20 -20
  133. package/dist/string/index.mjs +12 -12
  134. package/package.json +10 -6
  135. package/dist/_chunk/{pad-BWiShN.js → upperFirst-BUECmK.js} +84 -84
@@ -18,41 +18,96 @@ function camelCase(str) {
18
18
  return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
19
19
  }
20
20
 
21
- function snakeCase(str) {
22
- const words = getWords(str);
23
- return words.map(word => word.toLowerCase()).join('_');
24
- }
25
-
26
- function kebabCase(str) {
21
+ function constantCase(str) {
27
22
  const words = getWords(str);
28
- return words.map(word => word.toLowerCase()).join('-');
23
+ return words.map(word => word.toUpperCase()).join('_');
29
24
  }
30
25
 
31
- function upperCase(str) {
32
- const words = getWords(str);
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');
33
59
  let result = '';
34
- for (let i = 0; i < words.length; i++) {
35
- result += words[i].toUpperCase();
36
- if (i < words.length - 1) {
37
- 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;
38
64
  }
65
+ result += deburrMap.get(char) ?? char;
39
66
  }
40
67
  return result;
41
68
  }
42
69
 
70
+ const htmlEscapes = {
71
+ '&': '&amp;',
72
+ '<': '&lt;',
73
+ '>': '&gt;',
74
+ '"': '&quot;',
75
+ "'": '&#39;',
76
+ };
77
+ function escape(str) {
78
+ return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
79
+ }
80
+
81
+ function escapeRegExp(str) {
82
+ return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
83
+ }
84
+
85
+ function kebabCase(str) {
86
+ const words = getWords(str);
87
+ return words.map(word => word.toLowerCase()).join('-');
88
+ }
89
+
43
90
  function lowerCase(str) {
44
91
  const words = getWords(str);
45
92
  return words.map(word => word.toLowerCase()).join(' ');
46
93
  }
47
94
 
95
+ function lowerFirst(str) {
96
+ return str.substring(0, 1).toLowerCase() + str.substring(1);
97
+ }
98
+
99
+ function pad(str, length, chars = ' ') {
100
+ return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
101
+ }
102
+
48
103
  function pascalCase(str) {
49
104
  const words = getWords(str);
50
105
  return words.map(word => capitalize(word)).join('');
51
106
  }
52
107
 
53
- function constantCase(str) {
108
+ function snakeCase(str) {
54
109
  const words = getWords(str);
55
- return words.map(word => word.toUpperCase()).join('_');
110
+ return words.map(word => word.toLowerCase()).join('_');
56
111
  }
57
112
 
58
113
  function trimEnd(str, chars) {
@@ -104,73 +159,6 @@ function trim(str, chars) {
104
159
  return trimStart(trimEnd(str, chars), chars);
105
160
  }
106
161
 
107
- function upperFirst(str) {
108
- return str.substring(0, 1).toUpperCase() + str.substring(1);
109
- }
110
-
111
- function lowerFirst(str) {
112
- return str.substring(0, 1).toLowerCase() + str.substring(1);
113
- }
114
-
115
- const deburrMap = new Map(Object.entries({
116
- Æ: 'Ae',
117
- Ð: 'D',
118
- Ø: 'O',
119
- Þ: 'Th',
120
- ß: 'ss',
121
- æ: 'ae',
122
- ð: 'd',
123
- ø: 'o',
124
- þ: 'th',
125
- Đ: 'D',
126
- đ: 'd',
127
- Ħ: 'H',
128
- ħ: 'h',
129
- ı: 'i',
130
- IJ: 'IJ',
131
- ij: 'ij',
132
- ĸ: 'k',
133
- Ŀ: 'L',
134
- ŀ: 'l',
135
- Ł: 'L',
136
- ł: 'l',
137
- ʼn: "'n",
138
- Ŋ: 'N',
139
- ŋ: 'n',
140
- Œ: 'Oe',
141
- œ: 'oe',
142
- Ŧ: 'T',
143
- ŧ: 't',
144
- ſ: 's',
145
- }));
146
- function deburr(str) {
147
- str = str.normalize('NFD');
148
- let result = '';
149
- for (let i = 0; i < str.length; i++) {
150
- const char = str[i];
151
- if ((char >= '\u0300' && char <= '\u036f') || (char >= '\ufe20' && char <= '\ufe23')) {
152
- continue;
153
- }
154
- result += deburrMap.get(char) ?? char;
155
- }
156
- return result;
157
- }
158
-
159
- const htmlEscapes = {
160
- '&': '&amp;',
161
- '<': '&lt;',
162
- '>': '&gt;',
163
- '"': '&quot;',
164
- "'": '&#39;',
165
- };
166
- function escape(str) {
167
- return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
168
- }
169
-
170
- function escapeRegExp(str) {
171
- return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
172
- }
173
-
174
162
  const htmlUnescapes = {
175
163
  '&amp;': '&',
176
164
  '&lt;': '<',
@@ -182,8 +170,20 @@ function unescape(str) {
182
170
  return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, match => htmlUnescapes[match] || "'");
183
171
  }
184
172
 
185
- function pad(str, length, chars = ' ') {
186
- return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
173
+ function upperCase(str) {
174
+ const words = getWords(str);
175
+ let result = '';
176
+ for (let i = 0; i < words.length; i++) {
177
+ result += words[i].toUpperCase();
178
+ if (i < words.length - 1) {
179
+ result += ' ';
180
+ }
181
+ }
182
+ return result;
183
+ }
184
+
185
+ function upperFirst(str) {
186
+ return str.substring(0, 1).toUpperCase() + str.substring(1);
187
187
  }
188
188
 
189
189
  exports.camelCase = camelCase;