es-toolkit 1.23.0-dev.744 → 1.23.0-dev.745
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/README.md +1 -1
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +73 -73
- package/dist/compat/index.d.ts +73 -73
- package/dist/compat/index.js +556 -556
- package/dist/compat/index.mjs +72 -72
- package/dist/compat/string/upperCase.mjs +1 -1
- package/dist/index.d.mts +32 -32
- package/dist/index.d.ts +32 -32
- package/dist/index.js +40 -40
- package/dist/index.mjs +32 -32
- package/dist/math/index.d.mts +2 -2
- package/dist/math/index.d.ts +2 -2
- package/dist/math/index.js +9 -9
- package/dist/math/index.mjs +2 -2
- 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/predicate/index.d.mts +10 -10
- package/dist/predicate/index.d.ts +10 -10
- package/dist/predicate/index.js +7 -7
- package/dist/predicate/index.mjs +10 -10
- 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 +5 -1
- package/dist/_chunk/{isWeakSet-CjpFwn.js → isWeakSet-Bd6nry.js} +45 -45
- package/dist/_chunk/{rangeRight-CtcxMd.js → sumBy-BkErWJ.js} +5 -5
- package/dist/_chunk/{isObjectLike-aywuSF.js → toMerged-BBJZIl.js} +86 -86
- package/dist/_chunk/{pad-BWiShN.js → upperFirst-BUECmK.js} +84 -84
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.23.0-dev.
|
|
4
|
+
"version": "1.23.0-dev.745+df19ff14",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -237,6 +237,7 @@
|
|
|
237
237
|
"globals": "^15.9.0",
|
|
238
238
|
"jscodeshift": "^17.0.0",
|
|
239
239
|
"prettier": "^3.2.5",
|
|
240
|
+
"prettier-plugin-sort-re-exports": "^0.0.1",
|
|
240
241
|
"rollup": "^4.19.0",
|
|
241
242
|
"rollup-plugin-dts": "^6.1.1",
|
|
242
243
|
"tar": "^6",
|
|
@@ -249,6 +250,9 @@
|
|
|
249
250
|
"dependenciesMeta": {
|
|
250
251
|
"@trivago/prettier-plugin-sort-imports@4.3.0": {
|
|
251
252
|
"unplugged": true
|
|
253
|
+
},
|
|
254
|
+
"prettier-plugin-sort-re-exports@0.0.1": {
|
|
255
|
+
"unplugged": true
|
|
252
256
|
}
|
|
253
257
|
},
|
|
254
258
|
"sideEffects": false,
|
|
@@ -242,43 +242,26 @@ function isEqual(a, b) {
|
|
|
242
242
|
return isEqualWith(a, b, noop.noop);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
function isMap(value) {
|
|
246
|
-
return value instanceof Map;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function isNil(x) {
|
|
250
|
-
return x == null;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function isNotNil(x) {
|
|
254
|
-
return x != null;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function isNull(x) {
|
|
258
|
-
return x === null;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function isUndefined(x) {
|
|
262
|
-
return x === undefined;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function isLength(value) {
|
|
266
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
245
|
function isFunction(value) {
|
|
270
246
|
return typeof value === 'function';
|
|
271
247
|
}
|
|
272
248
|
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function isJSONArray(value) {
|
|
278
|
-
if (!Array.isArray(value)) {
|
|
249
|
+
function isJSONObject(obj) {
|
|
250
|
+
if (!isPlainObject.isPlainObject(obj)) {
|
|
279
251
|
return false;
|
|
280
252
|
}
|
|
281
|
-
|
|
253
|
+
const keys = Reflect.ownKeys(obj);
|
|
254
|
+
for (let i = 0; i < keys.length; i++) {
|
|
255
|
+
const key = keys[i];
|
|
256
|
+
const value = obj[key];
|
|
257
|
+
if (typeof key !== 'string') {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
if (!isJSONValue(value)) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return true;
|
|
282
265
|
}
|
|
283
266
|
|
|
284
267
|
function isJSONValue(value) {
|
|
@@ -297,28 +280,45 @@ function isJSONValue(value) {
|
|
|
297
280
|
}
|
|
298
281
|
}
|
|
299
282
|
|
|
300
|
-
function
|
|
301
|
-
if (!
|
|
283
|
+
function isJSONArray(value) {
|
|
284
|
+
if (!Array.isArray(value)) {
|
|
302
285
|
return false;
|
|
303
286
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
287
|
+
return value.every(item => isJSONValue(item));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function isLength(value) {
|
|
291
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function isMap(value) {
|
|
295
|
+
return value instanceof Map;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function isNil(x) {
|
|
299
|
+
return x == null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function isNotNil(x) {
|
|
303
|
+
return x != null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function isNull(x) {
|
|
307
|
+
return x === null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function isRegExp(value) {
|
|
311
|
+
return value instanceof RegExp;
|
|
316
312
|
}
|
|
317
313
|
|
|
318
314
|
function isSet(value) {
|
|
319
315
|
return value instanceof Set;
|
|
320
316
|
}
|
|
321
317
|
|
|
318
|
+
function isUndefined(x) {
|
|
319
|
+
return x === undefined;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
322
|
function isWeakMap(value) {
|
|
323
323
|
return value instanceof WeakMap;
|
|
324
324
|
}
|
|
@@ -35,11 +35,6 @@ function meanBy(items, getValue) {
|
|
|
35
35
|
return mean(nums);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function sumBy(items, getValue) {
|
|
39
|
-
const nums = items.map(x => getValue(x));
|
|
40
|
-
return sum(nums);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
function range(start, end, step) {
|
|
44
39
|
if (end == null) {
|
|
45
40
|
end = start;
|
|
@@ -78,6 +73,11 @@ function rangeRight(start, end, step) {
|
|
|
78
73
|
return result;
|
|
79
74
|
}
|
|
80
75
|
|
|
76
|
+
function sumBy(items, getValue) {
|
|
77
|
+
const nums = items.map(x => getValue(x));
|
|
78
|
+
return sum(nums);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
81
|
exports.clamp = clamp;
|
|
82
82
|
exports.inRange = inRange;
|
|
83
83
|
exports.mean = mean;
|
|
@@ -2,41 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const isPlainObject = require('./isPlainObject-DgrsU7.js');
|
|
4
4
|
|
|
5
|
-
function omitBy(obj, shouldOmit) {
|
|
6
|
-
const result = {};
|
|
7
|
-
const objEntries = Object.entries(obj);
|
|
8
|
-
for (let i = 0; i < objEntries.length; i++) {
|
|
9
|
-
const [key, value] = objEntries[i];
|
|
10
|
-
if (!shouldOmit(value, key)) {
|
|
11
|
-
result[key] = value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function pickBy(obj, shouldPick) {
|
|
18
|
-
const result = {};
|
|
19
|
-
const objEntries = Object.entries(obj);
|
|
20
|
-
for (let i = 0; i < objEntries.length; i++) {
|
|
21
|
-
const [key, value] = objEntries[i];
|
|
22
|
-
if (shouldPick(value, key)) {
|
|
23
|
-
result[key] = value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function invert(obj) {
|
|
30
|
-
const result = {};
|
|
31
|
-
const keys = Object.keys(obj);
|
|
32
|
-
for (let i = 0; i < keys.length; i++) {
|
|
33
|
-
const key = keys[i];
|
|
34
|
-
const value = obj[key];
|
|
35
|
-
result[value] = key;
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
5
|
function clone(obj) {
|
|
41
6
|
if (isPlainObject.isPrimitive(obj)) {
|
|
42
7
|
return obj;
|
|
@@ -78,53 +43,6 @@ function clone(obj) {
|
|
|
78
43
|
return obj;
|
|
79
44
|
}
|
|
80
45
|
|
|
81
|
-
function flattenObject(object) {
|
|
82
|
-
return flattenObjectImpl(object);
|
|
83
|
-
}
|
|
84
|
-
function flattenObjectImpl(object, prefix = '') {
|
|
85
|
-
const result = {};
|
|
86
|
-
const keys = Object.keys(object);
|
|
87
|
-
for (let i = 0; i < keys.length; i++) {
|
|
88
|
-
const key = keys[i];
|
|
89
|
-
const value = object[key];
|
|
90
|
-
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
91
|
-
if (isPlainObject.isPlainObject(value) && Object.keys(value).length > 0) {
|
|
92
|
-
Object.assign(result, flattenObjectImpl(value, prefixedKey));
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (Array.isArray(value)) {
|
|
96
|
-
for (let index = 0; index < value.length; index++) {
|
|
97
|
-
result[`${prefixedKey}.${index}`] = value[index];
|
|
98
|
-
}
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
result[prefixedKey] = value;
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function mapKeys(object, getNewKey) {
|
|
107
|
-
const result = {};
|
|
108
|
-
const keys = Object.keys(object);
|
|
109
|
-
for (let i = 0; i < keys.length; i++) {
|
|
110
|
-
const key = keys[i];
|
|
111
|
-
const value = object[key];
|
|
112
|
-
result[getNewKey(value, key, object)] = value;
|
|
113
|
-
}
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function mapValues(object, getNewValue) {
|
|
118
|
-
const result = {};
|
|
119
|
-
const keys = Object.keys(object);
|
|
120
|
-
for (let i = 0; i < keys.length; i++) {
|
|
121
|
-
const key = keys[i];
|
|
122
|
-
const value = object[key];
|
|
123
|
-
result[key] = getNewValue(value, key, object);
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
46
|
function cloneDeep(obj) {
|
|
129
47
|
return cloneDeepImpl(obj);
|
|
130
48
|
}
|
|
@@ -234,6 +152,64 @@ function copyProperties(target, source, stack) {
|
|
|
234
152
|
}
|
|
235
153
|
}
|
|
236
154
|
|
|
155
|
+
function flattenObject(object) {
|
|
156
|
+
return flattenObjectImpl(object);
|
|
157
|
+
}
|
|
158
|
+
function flattenObjectImpl(object, prefix = '') {
|
|
159
|
+
const result = {};
|
|
160
|
+
const keys = Object.keys(object);
|
|
161
|
+
for (let i = 0; i < keys.length; i++) {
|
|
162
|
+
const key = keys[i];
|
|
163
|
+
const value = object[key];
|
|
164
|
+
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
165
|
+
if (isPlainObject.isPlainObject(value) && Object.keys(value).length > 0) {
|
|
166
|
+
Object.assign(result, flattenObjectImpl(value, prefixedKey));
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (Array.isArray(value)) {
|
|
170
|
+
for (let index = 0; index < value.length; index++) {
|
|
171
|
+
result[`${prefixedKey}.${index}`] = value[index];
|
|
172
|
+
}
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
result[prefixedKey] = value;
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function invert(obj) {
|
|
181
|
+
const result = {};
|
|
182
|
+
const keys = Object.keys(obj);
|
|
183
|
+
for (let i = 0; i < keys.length; i++) {
|
|
184
|
+
const key = keys[i];
|
|
185
|
+
const value = obj[key];
|
|
186
|
+
result[value] = key;
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function mapKeys(object, getNewKey) {
|
|
192
|
+
const result = {};
|
|
193
|
+
const keys = Object.keys(object);
|
|
194
|
+
for (let i = 0; i < keys.length; i++) {
|
|
195
|
+
const key = keys[i];
|
|
196
|
+
const value = object[key];
|
|
197
|
+
result[getNewKey(value, key, object)] = value;
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function mapValues(object, getNewValue) {
|
|
203
|
+
const result = {};
|
|
204
|
+
const keys = Object.keys(object);
|
|
205
|
+
for (let i = 0; i < keys.length; i++) {
|
|
206
|
+
const key = keys[i];
|
|
207
|
+
const value = object[key];
|
|
208
|
+
result[key] = getNewValue(value, key, object);
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
|
|
237
213
|
function merge(target, source) {
|
|
238
214
|
const sourceKeys = Object.keys(source);
|
|
239
215
|
for (let i = 0; i < sourceKeys.length; i++) {
|
|
@@ -263,14 +239,38 @@ function merge(target, source) {
|
|
|
263
239
|
return target;
|
|
264
240
|
}
|
|
265
241
|
|
|
266
|
-
function toMerged(target, source) {
|
|
267
|
-
return merge(cloneDeep(target), source);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
242
|
function isObjectLike(value) {
|
|
271
243
|
return typeof value === 'object' && value !== null;
|
|
272
244
|
}
|
|
273
245
|
|
|
246
|
+
function omitBy(obj, shouldOmit) {
|
|
247
|
+
const result = {};
|
|
248
|
+
const objEntries = Object.entries(obj);
|
|
249
|
+
for (let i = 0; i < objEntries.length; i++) {
|
|
250
|
+
const [key, value] = objEntries[i];
|
|
251
|
+
if (!shouldOmit(value, key)) {
|
|
252
|
+
result[key] = value;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function pickBy(obj, shouldPick) {
|
|
259
|
+
const result = {};
|
|
260
|
+
const objEntries = Object.entries(obj);
|
|
261
|
+
for (let i = 0; i < objEntries.length; i++) {
|
|
262
|
+
const [key, value] = objEntries[i];
|
|
263
|
+
if (shouldPick(value, key)) {
|
|
264
|
+
result[key] = value;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function toMerged(target, source) {
|
|
271
|
+
return merge(cloneDeep(target), source);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
274
|
exports.clone = clone;
|
|
275
275
|
exports.cloneDeep = cloneDeep;
|
|
276
276
|
exports.copyProperties = copyProperties;
|
|
@@ -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;
|