es-toolkit 1.34.1-dev.1156 → 1.34.1-dev.1158
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/{isWeakSet-C2NpfO.js → isPromise-CJHbQD.js} +58 -58
- package/dist/_chunk/partialRight-B0_CSB.js +50 -0
- package/dist/_chunk/{upperFirst-DO8xaZ.js → reverseString-D-wK2p.js} +23 -94
- package/dist/_chunk/snakeCase-BtVEeB.js +75 -0
- package/dist/_chunk/toMerged-4hkLjP.js +579 -0
- package/dist/_chunk/{unary-c1NFA5.js → unary-DI8L2Y.js} +0 -48
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +2 -0
- package/dist/compat/index.d.ts +2 -0
- package/dist/compat/index.js +113 -312
- package/dist/compat/index.mjs +2 -0
- package/dist/function/index.js +4 -3
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +57 -53
- package/dist/index.mjs +2 -0
- package/dist/object/camelizeKeys.d.mts +22 -0
- package/dist/object/camelizeKeys.d.ts +22 -0
- package/dist/object/camelizeKeys.mjs +35 -0
- package/dist/object/index.d.mts +2 -0
- package/dist/object/index.d.ts +2 -0
- package/dist/object/index.js +3 -1
- package/dist/object/index.mjs +2 -0
- package/dist/object/snakeizeKeys.d.mts +22 -0
- package/dist/object/snakeizeKeys.d.ts +22 -0
- package/dist/object/snakeizeKeys.mjs +35 -0
- package/dist/predicate/index.js +28 -28
- package/dist/string/index.js +23 -22
- package/package.json +1 -1
- package/dist/_chunk/toMerged-CwnQF6.js +0 -320
- package/dist/_chunk/{isPlainObject-Xaozpc.js → isPlainObject-DwqRvh.js} +4 -4
|
@@ -1,33 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const isPlainObject = require('./isPlainObject-
|
|
3
|
+
const isPlainObject = require('./isPlainObject-DwqRvh.js');
|
|
4
4
|
const noop = require('./noop-2IwLUk.js');
|
|
5
5
|
|
|
6
|
-
function
|
|
7
|
-
return value
|
|
6
|
+
function isLength(value) {
|
|
7
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return x instanceof Blob;
|
|
10
|
+
function eq(value, other) {
|
|
11
|
+
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
function
|
|
18
|
-
return
|
|
14
|
+
function isNil(x) {
|
|
15
|
+
return x == null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isNull(x) {
|
|
19
|
+
return x === null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isUndefined(x) {
|
|
23
|
+
return x === undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isSymbol(value) {
|
|
27
|
+
return typeof value === 'symbol';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isFunction(value) {
|
|
31
|
+
return typeof value === 'function';
|
|
19
32
|
}
|
|
20
33
|
|
|
21
34
|
function isBuffer(x) {
|
|
22
35
|
return typeof Buffer !== 'undefined' && Buffer.isBuffer(x);
|
|
23
36
|
}
|
|
24
37
|
|
|
25
|
-
function
|
|
26
|
-
return value instanceof
|
|
38
|
+
function isArrayBuffer(value) {
|
|
39
|
+
return value instanceof ArrayBuffer;
|
|
27
40
|
}
|
|
28
41
|
|
|
29
|
-
function
|
|
30
|
-
return value
|
|
42
|
+
function isDate(value) {
|
|
43
|
+
return value instanceof Date;
|
|
31
44
|
}
|
|
32
45
|
|
|
33
46
|
function isEqualWith(a, b, areValuesEqual) {
|
|
@@ -208,6 +221,37 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
208
221
|
}
|
|
209
222
|
}
|
|
210
223
|
|
|
224
|
+
function isMap(value) {
|
|
225
|
+
return value instanceof Map;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function isRegExp(value) {
|
|
229
|
+
return value instanceof RegExp;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function isSet(value) {
|
|
233
|
+
return value instanceof Set;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function isWeakMap(value) {
|
|
237
|
+
return value instanceof WeakMap;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function isWeakSet(value) {
|
|
241
|
+
return value instanceof WeakSet;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function isBlob(x) {
|
|
245
|
+
if (typeof Blob === 'undefined') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return x instanceof Blob;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function isBrowser() {
|
|
252
|
+
return typeof window !== 'undefined' && window?.document != null;
|
|
253
|
+
}
|
|
254
|
+
|
|
211
255
|
function isEqual(a, b) {
|
|
212
256
|
return isEqualWith(a, b, noop.noop);
|
|
213
257
|
}
|
|
@@ -219,10 +263,6 @@ function isFile(x) {
|
|
|
219
263
|
return isBlob(x) && x instanceof File;
|
|
220
264
|
}
|
|
221
265
|
|
|
222
|
-
function isFunction(value) {
|
|
223
|
-
return typeof value === 'function';
|
|
224
|
-
}
|
|
225
|
-
|
|
226
266
|
function isJSON(value) {
|
|
227
267
|
if (typeof value !== 'string') {
|
|
228
268
|
return false;
|
|
@@ -275,18 +315,6 @@ function isJSONObject(obj) {
|
|
|
275
315
|
return true;
|
|
276
316
|
}
|
|
277
317
|
|
|
278
|
-
function isLength(value) {
|
|
279
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
function isMap(value) {
|
|
283
|
-
return value instanceof Map;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function isNil(x) {
|
|
287
|
-
return x == null;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
318
|
function isNode() {
|
|
291
319
|
return typeof process !== 'undefined' && process?.versions?.node != null;
|
|
292
320
|
}
|
|
@@ -295,38 +323,10 @@ function isNotNil(x) {
|
|
|
295
323
|
return x != null;
|
|
296
324
|
}
|
|
297
325
|
|
|
298
|
-
function isNull(x) {
|
|
299
|
-
return x === null;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
326
|
function isPromise(value) {
|
|
303
327
|
return value instanceof Promise;
|
|
304
328
|
}
|
|
305
329
|
|
|
306
|
-
function isRegExp(value) {
|
|
307
|
-
return value instanceof RegExp;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function isSet(value) {
|
|
311
|
-
return value instanceof Set;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function isSymbol(value) {
|
|
315
|
-
return typeof value === 'symbol';
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function isUndefined(x) {
|
|
319
|
-
return x === undefined;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function isWeakMap(value) {
|
|
323
|
-
return value instanceof WeakMap;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function isWeakSet(value) {
|
|
327
|
-
return value instanceof WeakSet;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
330
|
exports.eq = eq;
|
|
331
331
|
exports.isArrayBuffer = isArrayBuffer;
|
|
332
332
|
exports.isBlob = isBlob;
|
|
@@ -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
|
-
|
|
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
|
'&': '&',
|
|
@@ -83,13 +18,13 @@ function escapeRegExp(str) {
|
|
|
83
18
|
}
|
|
84
19
|
|
|
85
20
|
function kebabCase(str) {
|
|
86
|
-
const words
|
|
87
|
-
return words
|
|
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
|
|
92
|
-
return words
|
|
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();
|
|
@@ -178,11 +99,11 @@ function unescape(str) {
|
|
|
178
99
|
}
|
|
179
100
|
|
|
180
101
|
function upperCase(str) {
|
|
181
|
-
const words
|
|
102
|
+
const words = snakeCase.words(str);
|
|
182
103
|
let result = '';
|
|
183
|
-
for (let i = 0; i < words
|
|
184
|
-
result += words
|
|
185
|
-
if (i < words
|
|
104
|
+
for (let i = 0; i < words.length; i++) {
|
|
105
|
+
result += words[i].toUpperCase();
|
|
106
|
+
if (i < words.length - 1) {
|
|
186
107
|
result += ' ';
|
|
187
108
|
}
|
|
188
109
|
}
|
|
@@ -193,11 +114,21 @@ function upperFirst(str) {
|
|
|
193
114
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
194
115
|
}
|
|
195
116
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
+
|
|
199
131
|
exports.constantCase = constantCase;
|
|
200
|
-
exports.deburr = deburr;
|
|
201
132
|
exports.escape = escape;
|
|
202
133
|
exports.escapeRegExp = escapeRegExp;
|
|
203
134
|
exports.kebabCase = kebabCase;
|
|
@@ -206,11 +137,9 @@ exports.lowerFirst = lowerFirst;
|
|
|
206
137
|
exports.pad = pad;
|
|
207
138
|
exports.pascalCase = pascalCase;
|
|
208
139
|
exports.reverseString = reverseString;
|
|
209
|
-
exports.snakeCase = snakeCase;
|
|
210
140
|
exports.trim = trim;
|
|
211
141
|
exports.trimEnd = trimEnd;
|
|
212
142
|
exports.trimStart = trimStart;
|
|
213
143
|
exports.unescape = unescape;
|
|
214
144
|
exports.upperCase = upperCase;
|
|
215
145
|
exports.upperFirst = upperFirst;
|
|
216
|
-
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;
|