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.
- package/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/dist/_chunk/{isWeakSet-BAMm2l.js → isWeakSet-Bd6nry.js} +59 -46
- package/dist/_chunk/{range-BXlMmn.js → sumBy-BkErWJ.js} +25 -5
- package/dist/_chunk/{isObjectLike-aywuSF.js → toMerged-DDLv0D.js} +88 -86
- package/dist/_chunk/{flowRight-Dv8J0U.js → unary-BZ5Ixo.js} +27 -64
- package/dist/_chunk/{zipWith-EOU_KZ.js → zipWith-wpjySR.js} +8 -17
- package/dist/array/dropRightWhile.d.mts +2 -2
- package/dist/array/dropRightWhile.d.ts +2 -2
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.d.mts +1 -1
- package/dist/array/dropWhile.d.ts +1 -1
- package/dist/array/index.js +1 -1
- package/dist/array/unionBy.mjs +3 -10
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/MAX_ARRAY_LENGTH.mjs +3 -0
- package/dist/compat/_internal/isIterateeCall.mjs +17 -0
- package/dist/compat/array/difference.d.mts +9 -3
- package/dist/compat/array/difference.d.ts +9 -3
- package/dist/compat/array/difference.mjs +12 -3
- package/dist/compat/array/dropRightWhile.d.mts +60 -0
- package/dist/compat/array/dropRightWhile.d.ts +60 -0
- package/dist/compat/array/dropRightWhile.mjs +27 -0
- package/dist/compat/array/every.mjs +4 -5
- package/dist/compat/array/filter.mjs +4 -5
- package/dist/compat/array/find.mjs +4 -5
- package/dist/compat/array/includes.mjs +2 -1
- package/dist/compat/array/slice.d.mts +18 -0
- package/dist/compat/array/slice.d.ts +18 -0
- package/dist/compat/array/slice.mjs +38 -0
- package/dist/compat/array/take.d.mts +25 -0
- package/dist/compat/array/take.d.ts +25 -0
- package/dist/compat/array/take.mjs +10 -0
- package/dist/compat/function/before.d.mts +26 -0
- package/dist/compat/function/before.d.ts +26 -0
- package/dist/compat/function/before.mjs +20 -0
- package/dist/compat/function/curryRight.d.mts +50 -0
- package/dist/compat/function/curryRight.d.ts +50 -0
- package/dist/compat/function/curryRight.mjs +64 -0
- package/dist/compat/index.d.mts +86 -75
- package/dist/compat/index.d.ts +86 -75
- package/dist/compat/index.js +779 -496
- package/dist/compat/index.mjs +86 -75
- package/dist/compat/object/defaults.d.mts +120 -0
- package/dist/compat/object/defaults.d.ts +120 -0
- package/dist/compat/object/defaults.mjs +21 -0
- package/dist/compat/object/invertBy.d.mts +27 -0
- package/dist/compat/object/invertBy.d.ts +27 -0
- package/dist/compat/object/invertBy.mjs +27 -0
- package/dist/compat/object/omit.d.mts +1 -1
- package/dist/compat/object/omit.d.ts +1 -1
- package/dist/compat/object/pick.d.mts +1 -1
- package/dist/compat/object/pick.d.ts +1 -1
- package/dist/compat/object/toDefaulted.d.mts +122 -0
- package/dist/compat/object/toDefaulted.d.ts +122 -0
- package/dist/compat/object/toDefaulted.mjs +9 -0
- package/dist/compat/predicate/isArrayBuffer.d.mts +20 -0
- package/dist/compat/predicate/isArrayBuffer.d.ts +20 -0
- package/dist/compat/predicate/isArrayBuffer.mjs +7 -0
- package/dist/compat/predicate/isDate.d.mts +16 -0
- package/dist/compat/predicate/isDate.d.ts +16 -0
- package/dist/compat/predicate/isDate.mjs +7 -0
- package/dist/compat/predicate/isEqualWith.d.mts +38 -0
- package/dist/compat/predicate/isEqualWith.d.ts +38 -0
- package/dist/compat/predicate/isEqualWith.mjs +23 -0
- package/dist/compat/predicate/isMap.d.mts +20 -0
- package/dist/compat/predicate/isMap.d.ts +20 -0
- package/dist/compat/predicate/isMap.mjs +7 -0
- package/dist/compat/predicate/isMatch.mjs +2 -1
- package/dist/compat/predicate/isSet.d.mts +20 -0
- package/dist/compat/predicate/isSet.d.ts +20 -0
- package/dist/compat/predicate/isSet.mjs +7 -0
- package/dist/compat/string/upperCase.mjs +0 -1
- package/dist/compat/util/constant.d.mts +16 -0
- package/dist/compat/util/constant.d.ts +16 -0
- package/dist/compat/util/constant.mjs +5 -0
- package/dist/compat/util/defaultTo.d.mts +17 -0
- package/dist/compat/util/defaultTo.d.ts +17 -0
- package/dist/compat/util/defaultTo.mjs +8 -0
- package/dist/compat/util/eq.d.mts +16 -0
- package/dist/compat/util/eq.d.ts +16 -0
- package/dist/compat/util/eq.mjs +5 -0
- package/dist/compat/util/times.d.mts +14 -0
- package/dist/compat/util/times.d.ts +14 -0
- package/dist/compat/util/times.mjs +15 -0
- package/dist/compat/util/toLength.d.mts +18 -0
- package/dist/compat/util/toLength.d.ts +18 -0
- package/dist/compat/util/toLength.mjs +12 -0
- package/dist/function/before.d.mts +2 -2
- package/dist/function/before.d.ts +2 -2
- package/dist/function/before.mjs +2 -2
- package/dist/function/index.d.mts +10 -10
- package/dist/function/index.d.ts +10 -10
- package/dist/function/index.js +65 -32
- package/dist/function/index.mjs +10 -10
- package/dist/function/once.d.mts +16 -1
- package/dist/function/once.d.ts +16 -1
- package/dist/function/once.mjs +5 -7
- package/dist/index.d.mts +43 -41
- package/dist/index.d.ts +43 -41
- package/dist/index.js +59 -57
- package/dist/index.mjs +43 -41
- package/dist/math/index.d.mts +2 -1
- package/dist/math/index.d.ts +2 -1
- package/dist/math/index.js +9 -8
- package/dist/math/index.mjs +2 -1
- package/dist/math/rangeRight.d.mts +38 -0
- package/dist/math/rangeRight.d.ts +38 -0
- package/dist/math/rangeRight.mjs +20 -0
- package/dist/object/index.d.mts +7 -7
- package/dist/object/index.d.ts +7 -7
- package/dist/object/index.js +32 -32
- package/dist/object/index.mjs +7 -7
- package/dist/object/omitBy.d.mts +1 -1
- package/dist/object/omitBy.d.ts +1 -1
- package/dist/object/omitBy.mjs +4 -3
- package/dist/object/pickBy.mjs +4 -3
- package/dist/predicate/index.d.mts +11 -10
- package/dist/predicate/index.d.ts +11 -10
- package/dist/predicate/index.js +8 -7
- package/dist/predicate/index.mjs +11 -10
- package/dist/predicate/isBlob.d.mts +19 -0
- package/dist/predicate/isBlob.d.ts +19 -0
- package/dist/predicate/isBlob.mjs +8 -0
- package/dist/predicate/isEqualWith.mjs +2 -1
- package/dist/promise/index.d.mts +1 -1
- package/dist/promise/index.d.ts +1 -1
- package/dist/promise/index.mjs +1 -1
- package/dist/string/index.d.mts +12 -12
- package/dist/string/index.d.ts +12 -12
- package/dist/string/index.js +20 -20
- package/dist/string/index.mjs +12 -12
- package/package.json +10 -6
- 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
|
|
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.
|
|
23
|
+
return words.map(word => word.toUpperCase()).join('_');
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
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 <
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
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
|
+
'&': '&',
|
|
72
|
+
'<': '<',
|
|
73
|
+
'>': '>',
|
|
74
|
+
'"': '"',
|
|
75
|
+
"'": ''',
|
|
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
|
|
108
|
+
function snakeCase(str) {
|
|
54
109
|
const words = getWords(str);
|
|
55
|
-
return words.map(word => word.
|
|
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
|
-
'&': '&',
|
|
161
|
-
'<': '<',
|
|
162
|
-
'>': '>',
|
|
163
|
-
'"': '"',
|
|
164
|
-
"'": ''',
|
|
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
|
'&': '&',
|
|
176
164
|
'<': '<',
|
|
@@ -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
|
|
186
|
-
|
|
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;
|