es-toolkit 1.26.1-dev.837 → 1.26.1-dev.838
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/dist/_chunk/{isUndefined-C_iNqA.js → isWeakSet-D8h8bS.js} +37 -239
- package/dist/_chunk/noop-2IwLUk.js +5 -0
- package/dist/_chunk/{unary-DqRmr1.js → unary-CcTNuC.js} +48 -0
- package/dist/_chunk/{upperFirst-Dk8IW1.js → upperFirst-BUECmK.js} +74 -29
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/isPrototype.mjs +7 -0
- package/dist/compat/index.js +267 -79
- package/dist/compat/index.mjs +21 -21
- package/dist/compat/predicate/isDate.mjs +0 -7
- package/dist/compat/predicate/isEmpty.mjs +16 -7
- package/dist/function/index.js +5 -5
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +28 -30
- package/dist/index.mjs +0 -1
- package/dist/predicate/index.d.mts +0 -1
- package/dist/predicate/index.d.ts +0 -1
- package/dist/predicate/index.js +21 -22
- package/dist/predicate/index.mjs +0 -1
- package/dist/string/index.js +2 -3
- package/package.json +1 -1
- package/dist/_chunk/deburr-BPmkoM.js +0 -47
- package/dist/_chunk/partialRight-CRhV1h.js +0 -53
- package/dist/predicate/isEmpty.d.mts +0 -69
- package/dist/predicate/isEmpty.d.ts +0 -69
- package/dist/predicate/isEmpty.mjs +0 -31
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const partialRight = require('./partialRight-CRhV1h.js');
|
|
4
3
|
const isPlainObject = require('./isPlainObject-octpoD.js');
|
|
5
|
-
require('./
|
|
4
|
+
const noop = require('./noop-2IwLUk.js');
|
|
6
5
|
|
|
7
6
|
function isArrayBuffer(value) {
|
|
8
7
|
return value instanceof ArrayBuffer;
|
|
@@ -19,16 +18,11 @@ function isDate(value) {
|
|
|
19
18
|
return value instanceof Date;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return value != null && typeof value !== 'function' && isLength(value.length);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function eq(value, other) {
|
|
31
|
-
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
21
|
+
function getTag(value) {
|
|
22
|
+
if (value == null) {
|
|
23
|
+
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
24
|
+
}
|
|
25
|
+
return Object.prototype.toString.call(value);
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
const regexpTag = '[object RegExp]';
|
|
@@ -58,187 +52,9 @@ const bigInt64ArrayTag = '[object BigInt64Array]';
|
|
|
58
52
|
const float32ArrayTag = '[object Float32Array]';
|
|
59
53
|
const float64ArrayTag = '[object Float64Array]';
|
|
60
54
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
64
|
-
}
|
|
65
|
-
return Object.prototype.toString.call(value);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function isNil(x) {
|
|
69
|
-
return x == null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function bind(func, thisObj, ...partialArgs) {
|
|
73
|
-
const bound = function (...providedArgs) {
|
|
74
|
-
const args = [];
|
|
75
|
-
let startIndex = 0;
|
|
76
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
77
|
-
const arg = partialArgs[i];
|
|
78
|
-
if (arg === bind.placeholder) {
|
|
79
|
-
args.push(providedArgs[startIndex++]);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
args.push(arg);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
86
|
-
args.push(providedArgs[i]);
|
|
87
|
-
}
|
|
88
|
-
if (this instanceof bound) {
|
|
89
|
-
return new func(...args);
|
|
90
|
-
}
|
|
91
|
-
return func.apply(thisObj, args);
|
|
92
|
-
};
|
|
93
|
-
return bound;
|
|
94
|
-
}
|
|
95
|
-
const bindPlaceholder = Symbol('bind.placeholder');
|
|
96
|
-
bind.placeholder = bindPlaceholder;
|
|
97
|
-
|
|
98
|
-
function bindKey(object, key, ...partialArgs) {
|
|
99
|
-
const bound = function (...providedArgs) {
|
|
100
|
-
const args = [];
|
|
101
|
-
let startIndex = 0;
|
|
102
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
103
|
-
const arg = partialArgs[i];
|
|
104
|
-
if (arg === bindKey.placeholder) {
|
|
105
|
-
args.push(providedArgs[startIndex++]);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
args.push(arg);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
112
|
-
args.push(providedArgs[i]);
|
|
113
|
-
}
|
|
114
|
-
if (this instanceof bound) {
|
|
115
|
-
return new object[key](...args);
|
|
116
|
-
}
|
|
117
|
-
return object[key].apply(object, args);
|
|
118
|
-
};
|
|
119
|
-
return bound;
|
|
120
|
-
}
|
|
121
|
-
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
122
|
-
bindKey.placeholder = bindKeyPlaceholder;
|
|
123
|
-
|
|
124
|
-
function curry(func, arity = func.length, guard) {
|
|
125
|
-
arity = guard ? func.length : arity;
|
|
126
|
-
arity = Number.parseInt(arity, 10);
|
|
127
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
128
|
-
arity = 0;
|
|
129
|
-
}
|
|
130
|
-
const wrapper = function (...partialArgs) {
|
|
131
|
-
const holders = partialArgs.filter(item => item === curry.placeholder);
|
|
132
|
-
const length = partialArgs.length - holders.length;
|
|
133
|
-
if (length < arity) {
|
|
134
|
-
return makeCurry(func, arity - length, partialArgs);
|
|
135
|
-
}
|
|
136
|
-
if (this instanceof wrapper) {
|
|
137
|
-
return new func(...partialArgs);
|
|
138
|
-
}
|
|
139
|
-
return func.apply(this, partialArgs);
|
|
140
|
-
};
|
|
141
|
-
wrapper.placeholder = curryPlaceholder;
|
|
142
|
-
return wrapper;
|
|
143
|
-
}
|
|
144
|
-
function makeCurry(func, arity, partialArgs) {
|
|
145
|
-
function wrapper(...providedArgs) {
|
|
146
|
-
const holders = providedArgs.filter(item => item === curry.placeholder);
|
|
147
|
-
const length = providedArgs.length - holders.length;
|
|
148
|
-
providedArgs = composeArgs$1(providedArgs, partialArgs);
|
|
149
|
-
if (length < arity) {
|
|
150
|
-
return makeCurry(func, arity - length, providedArgs);
|
|
151
|
-
}
|
|
152
|
-
if (this instanceof wrapper) {
|
|
153
|
-
return new func(...providedArgs);
|
|
154
|
-
}
|
|
155
|
-
return func.apply(this, providedArgs);
|
|
156
|
-
}
|
|
157
|
-
wrapper.placeholder = curryPlaceholder;
|
|
158
|
-
return wrapper;
|
|
159
|
-
}
|
|
160
|
-
function composeArgs$1(providedArgs, partialArgs) {
|
|
161
|
-
const args = [];
|
|
162
|
-
let startIndex = 0;
|
|
163
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
164
|
-
const arg = partialArgs[i];
|
|
165
|
-
if (arg === curry.placeholder && startIndex < providedArgs.length) {
|
|
166
|
-
args.push(providedArgs[startIndex++]);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
args.push(arg);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
173
|
-
args.push(providedArgs[i]);
|
|
174
|
-
}
|
|
175
|
-
return args;
|
|
176
|
-
}
|
|
177
|
-
const curryPlaceholder = Symbol('curry.placeholder');
|
|
178
|
-
curry.placeholder = curryPlaceholder;
|
|
179
|
-
|
|
180
|
-
function curryRight(func, arity = func.length, guard) {
|
|
181
|
-
arity = guard ? func.length : arity;
|
|
182
|
-
arity = Number.parseInt(arity, 10);
|
|
183
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
184
|
-
arity = 0;
|
|
185
|
-
}
|
|
186
|
-
const wrapper = function (...partialArgs) {
|
|
187
|
-
const holders = partialArgs.filter(item => item === curryRight.placeholder);
|
|
188
|
-
const length = partialArgs.length - holders.length;
|
|
189
|
-
if (length < arity) {
|
|
190
|
-
return makeCurryRight(func, arity - length, partialArgs);
|
|
191
|
-
}
|
|
192
|
-
if (this instanceof wrapper) {
|
|
193
|
-
return new func(...partialArgs);
|
|
194
|
-
}
|
|
195
|
-
return func.apply(this, partialArgs);
|
|
196
|
-
};
|
|
197
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
198
|
-
return wrapper;
|
|
199
|
-
}
|
|
200
|
-
function makeCurryRight(func, arity, partialArgs) {
|
|
201
|
-
function wrapper(...providedArgs) {
|
|
202
|
-
const holders = providedArgs.filter(item => item === curryRight.placeholder);
|
|
203
|
-
const length = providedArgs.length - holders.length;
|
|
204
|
-
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
205
|
-
if (length < arity) {
|
|
206
|
-
return makeCurryRight(func, arity - length, providedArgs);
|
|
207
|
-
}
|
|
208
|
-
if (this instanceof wrapper) {
|
|
209
|
-
return new func(...providedArgs);
|
|
210
|
-
}
|
|
211
|
-
return func.apply(this, providedArgs);
|
|
212
|
-
}
|
|
213
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
214
|
-
return wrapper;
|
|
215
|
-
}
|
|
216
|
-
function composeArgs(providedArgs, partialArgs) {
|
|
217
|
-
const placeholderLength = partialArgs.filter(arg => arg === curryRight.placeholder).length;
|
|
218
|
-
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
219
|
-
const args = [];
|
|
220
|
-
let providedIndex = 0;
|
|
221
|
-
for (let i = 0; i < rangeLength; i++) {
|
|
222
|
-
args.push(providedArgs[providedIndex++]);
|
|
223
|
-
}
|
|
224
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
225
|
-
const arg = partialArgs[i];
|
|
226
|
-
if (arg === curryRight.placeholder) {
|
|
227
|
-
if (providedIndex < providedArgs.length) {
|
|
228
|
-
args.push(providedArgs[providedIndex++]);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
args.push(arg);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
args.push(arg);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return args;
|
|
55
|
+
function eq(value, other) {
|
|
56
|
+
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
239
57
|
}
|
|
240
|
-
const curryRightPlaceholder = Symbol('curryRight.placeholder');
|
|
241
|
-
curryRight.placeholder = curryRightPlaceholder;
|
|
242
58
|
|
|
243
59
|
function isEqualWith(a, b, areValuesEqual) {
|
|
244
60
|
return isEqualWithImpl(a, b, undefined, undefined, undefined, undefined, areValuesEqual);
|
|
@@ -418,48 +234,8 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
418
234
|
}
|
|
419
235
|
}
|
|
420
236
|
|
|
421
|
-
function isMap(value) {
|
|
422
|
-
return value instanceof Map;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function isRegExp(value) {
|
|
426
|
-
return value instanceof RegExp;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function isSet(value) {
|
|
430
|
-
return value instanceof Set;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function isWeakMap(value) {
|
|
434
|
-
return value instanceof WeakMap;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function isWeakSet(value) {
|
|
438
|
-
return value instanceof WeakSet;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function isEmpty(value) {
|
|
442
|
-
if (value == null) {
|
|
443
|
-
return true;
|
|
444
|
-
}
|
|
445
|
-
if (isArrayLike(value)) {
|
|
446
|
-
return value.length === 0;
|
|
447
|
-
}
|
|
448
|
-
if (value instanceof Map || value instanceof Set) {
|
|
449
|
-
return value.size === 0;
|
|
450
|
-
}
|
|
451
|
-
switch (typeof value) {
|
|
452
|
-
case 'object': {
|
|
453
|
-
return Object.keys(value).length === 0 && isPlainObject.getSymbols(value).length === 0;
|
|
454
|
-
}
|
|
455
|
-
default: {
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
237
|
function isEqual(a, b) {
|
|
462
|
-
return isEqualWith(a, b,
|
|
238
|
+
return isEqualWith(a, b, noop.noop);
|
|
463
239
|
}
|
|
464
240
|
|
|
465
241
|
function isFile(x) {
|
|
@@ -512,6 +288,18 @@ function isJSONObject(obj) {
|
|
|
512
288
|
return true;
|
|
513
289
|
}
|
|
514
290
|
|
|
291
|
+
function isLength(value) {
|
|
292
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function isMap(value) {
|
|
296
|
+
return value instanceof Map;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function isNil(x) {
|
|
300
|
+
return x == null;
|
|
301
|
+
}
|
|
302
|
+
|
|
515
303
|
function isNotNil(x) {
|
|
516
304
|
return x != null;
|
|
517
305
|
}
|
|
@@ -520,23 +308,33 @@ function isNull(x) {
|
|
|
520
308
|
return x === null;
|
|
521
309
|
}
|
|
522
310
|
|
|
311
|
+
function isRegExp(value) {
|
|
312
|
+
return value instanceof RegExp;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function isSet(value) {
|
|
316
|
+
return value instanceof Set;
|
|
317
|
+
}
|
|
318
|
+
|
|
523
319
|
function isUndefined(x) {
|
|
524
320
|
return x === undefined;
|
|
525
321
|
}
|
|
526
322
|
|
|
323
|
+
function isWeakMap(value) {
|
|
324
|
+
return value instanceof WeakMap;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function isWeakSet(value) {
|
|
328
|
+
return value instanceof WeakSet;
|
|
329
|
+
}
|
|
330
|
+
|
|
527
331
|
exports.argumentsTag = argumentsTag;
|
|
528
|
-
exports.bind = bind;
|
|
529
|
-
exports.bindKey = bindKey;
|
|
530
332
|
exports.booleanTag = booleanTag;
|
|
531
|
-
exports.curry = curry;
|
|
532
|
-
exports.curryRight = curryRight;
|
|
533
333
|
exports.eq = eq;
|
|
534
334
|
exports.getTag = getTag;
|
|
535
335
|
exports.isArrayBuffer = isArrayBuffer;
|
|
536
|
-
exports.isArrayLike = isArrayLike;
|
|
537
336
|
exports.isBlob = isBlob;
|
|
538
337
|
exports.isDate = isDate;
|
|
539
|
-
exports.isEmpty = isEmpty;
|
|
540
338
|
exports.isEqual = isEqual;
|
|
541
339
|
exports.isEqualWith = isEqualWith;
|
|
542
340
|
exports.isFile = isFile;
|
|
@@ -130,6 +130,52 @@ function once(func) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
function partial(func, ...partialArgs) {
|
|
134
|
+
return function (...providedArgs) {
|
|
135
|
+
const args = [];
|
|
136
|
+
let startIndex = 0;
|
|
137
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
138
|
+
const arg = partialArgs[i];
|
|
139
|
+
if (arg === partial.placeholder) {
|
|
140
|
+
args.push(providedArgs[startIndex++]);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
args.push(arg);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
147
|
+
args.push(providedArgs[i]);
|
|
148
|
+
}
|
|
149
|
+
return func.apply(this, args);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const partialPlaceholder = Symbol('partial.placeholder');
|
|
153
|
+
partial.placeholder = partialPlaceholder;
|
|
154
|
+
|
|
155
|
+
function partialRight(func, ...partialArgs) {
|
|
156
|
+
return function (...providedArgs) {
|
|
157
|
+
const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;
|
|
158
|
+
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
159
|
+
const args = [];
|
|
160
|
+
let providedIndex = 0;
|
|
161
|
+
for (let i = 0; i < rangeLength; i++) {
|
|
162
|
+
args.push(providedArgs[providedIndex++]);
|
|
163
|
+
}
|
|
164
|
+
for (let i = 0; i < partialArgs.length; i++) {
|
|
165
|
+
const arg = partialArgs[i];
|
|
166
|
+
if (arg === partialRight.placeholder) {
|
|
167
|
+
args.push(providedArgs[providedIndex++]);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
args.push(arg);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return func.apply(this, args);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const partialRightPlaceholder = Symbol('partialRight.placeholder');
|
|
177
|
+
partialRight.placeholder = partialRightPlaceholder;
|
|
178
|
+
|
|
133
179
|
function rest(func, startIndex = func.length - 1) {
|
|
134
180
|
return function (...args) {
|
|
135
181
|
const rest = args.slice(startIndex);
|
|
@@ -154,5 +200,7 @@ exports.identity = identity;
|
|
|
154
200
|
exports.memoize = memoize;
|
|
155
201
|
exports.negate = negate;
|
|
156
202
|
exports.once = once;
|
|
203
|
+
exports.partial = partial;
|
|
204
|
+
exports.partialRight = partialRight;
|
|
157
205
|
exports.rest = rest;
|
|
158
206
|
exports.unary = unary;
|
|
@@ -18,6 +18,55 @@ function camelCase(str) {
|
|
|
18
18
|
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function constantCase(str) {
|
|
22
|
+
const words = getWords(str);
|
|
23
|
+
return words.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
|
+
}
|
|
69
|
+
|
|
21
70
|
const htmlEscapes = {
|
|
22
71
|
'&': '&',
|
|
23
72
|
'<': '<',
|
|
@@ -29,6 +78,10 @@ function escape(str) {
|
|
|
29
78
|
return str.replace(/[&<>"']/g, match => htmlEscapes[match]);
|
|
30
79
|
}
|
|
31
80
|
|
|
81
|
+
function escapeRegExp(str) {
|
|
82
|
+
return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
83
|
+
}
|
|
84
|
+
|
|
32
85
|
function kebabCase(str) {
|
|
33
86
|
const words = getWords(str);
|
|
34
87
|
return words.map(word => word.toLowerCase()).join('-');
|
|
@@ -39,10 +92,19 @@ function lowerCase(str) {
|
|
|
39
92
|
return words.map(word => word.toLowerCase()).join(' ');
|
|
40
93
|
}
|
|
41
94
|
|
|
95
|
+
function lowerFirst(str) {
|
|
96
|
+
return str.substring(0, 1).toLowerCase() + str.substring(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
42
99
|
function pad(str, length, chars = ' ') {
|
|
43
100
|
return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
|
|
44
101
|
}
|
|
45
102
|
|
|
103
|
+
function pascalCase(str) {
|
|
104
|
+
const words = getWords(str);
|
|
105
|
+
return words.map(word => capitalize(word)).join('');
|
|
106
|
+
}
|
|
107
|
+
|
|
46
108
|
function snakeCase(str) {
|
|
47
109
|
const words = getWords(str);
|
|
48
110
|
return words.map(word => word.toLowerCase()).join('_');
|
|
@@ -97,6 +159,17 @@ function trim(str, chars) {
|
|
|
97
159
|
return trimStart(trimEnd(str, chars), chars);
|
|
98
160
|
}
|
|
99
161
|
|
|
162
|
+
const htmlUnescapes = {
|
|
163
|
+
'&': '&',
|
|
164
|
+
'<': '<',
|
|
165
|
+
'>': '>',
|
|
166
|
+
'"': '"',
|
|
167
|
+
''': "'",
|
|
168
|
+
};
|
|
169
|
+
function unescape(str) {
|
|
170
|
+
return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, match => htmlUnescapes[match] || "'");
|
|
171
|
+
}
|
|
172
|
+
|
|
100
173
|
function upperCase(str) {
|
|
101
174
|
const words = getWords(str);
|
|
102
175
|
let result = '';
|
|
@@ -109,35 +182,6 @@ function upperCase(str) {
|
|
|
109
182
|
return result;
|
|
110
183
|
}
|
|
111
184
|
|
|
112
|
-
function constantCase(str) {
|
|
113
|
-
const words = getWords(str);
|
|
114
|
-
return words.map(word => word.toUpperCase()).join('_');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function escapeRegExp(str) {
|
|
118
|
-
return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function lowerFirst(str) {
|
|
122
|
-
return str.substring(0, 1).toLowerCase() + str.substring(1);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function pascalCase(str) {
|
|
126
|
-
const words = getWords(str);
|
|
127
|
-
return words.map(word => capitalize(word)).join('');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const htmlUnescapes = {
|
|
131
|
-
'&': '&',
|
|
132
|
-
'<': '<',
|
|
133
|
-
'>': '>',
|
|
134
|
-
'"': '"',
|
|
135
|
-
''': "'",
|
|
136
|
-
};
|
|
137
|
-
function unescape(str) {
|
|
138
|
-
return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, match => htmlUnescapes[match] || "'");
|
|
139
|
-
}
|
|
140
|
-
|
|
141
185
|
function upperFirst(str) {
|
|
142
186
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
143
187
|
}
|
|
@@ -145,6 +189,7 @@ function upperFirst(str) {
|
|
|
145
189
|
exports.camelCase = camelCase;
|
|
146
190
|
exports.capitalize = capitalize;
|
|
147
191
|
exports.constantCase = constantCase;
|
|
192
|
+
exports.deburr = deburr;
|
|
148
193
|
exports.escape = escape;
|
|
149
194
|
exports.escapeRegExp = escapeRegExp;
|
|
150
195
|
exports.getWords = getWords;
|