es-toolkit 1.9.0-dev.177 → 1.9.0-dev.179
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/array/flattenDeep.d.mts +25 -0
- package/dist/array/flattenDeep.d.ts +25 -0
- package/dist/array/flattenDeep.js +52 -0
- package/dist/array/flattenDeep.js.map +1 -0
- package/dist/array/flattenDeep.mjs +9 -0
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +7 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +39 -35
- package/dist/chunk-HJPB4KC3.mjs +13 -0
- package/dist/chunk-HJPB4KC3.mjs.map +1 -0
- package/dist/chunk-MPBVTIU3.mjs +1 -0
- package/dist/chunk-OJSIDS6H.mjs +1 -0
- package/dist/chunk-OJSIDS6H.mjs.map +1 -0
- package/dist/chunk-U56ZOM7L.mjs +9 -0
- package/dist/chunk-U56ZOM7L.mjs.map +1 -0
- package/dist/function/index.mjs +3 -3
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -63
- package/dist/math/index.mjs +3 -3
- package/dist/object/index.mjs +3 -3
- package/dist/predicate/index.mjs +3 -3
- package/dist/string/capitalize.d.mts +14 -0
- package/dist/string/capitalize.d.ts +14 -0
- package/dist/string/capitalize.js +33 -0
- package/dist/string/capitalize.js.map +1 -0
- package/dist/string/capitalize.mjs +8 -0
- package/dist/string/capitalize.mjs.map +1 -0
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +7 -0
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +5 -1
- package/package.json +1 -1
- package/dist/chunk-NLN3GQ7D.mjs +0 -1
- package/dist/chunk-YOFIBRET.mjs +0 -1
- /package/dist/{chunk-NLN3GQ7D.mjs.map → array/flattenDeep.mjs.map} +0 -0
- /package/dist/{chunk-YOFIBRET.mjs.map → chunk-MPBVTIU3.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,17 @@ import "./chunk-ARZ5BDR6.mjs";
|
|
|
2
2
|
import {
|
|
3
3
|
delay
|
|
4
4
|
} from "./chunk-O64NE2P4.mjs";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-MPBVTIU3.mjs";
|
|
6
|
+
import {
|
|
7
|
+
capitalize
|
|
8
|
+
} from "./chunk-U56ZOM7L.mjs";
|
|
6
9
|
import {
|
|
7
10
|
snakeCase
|
|
8
11
|
} from "./chunk-VRFIBW4H.mjs";
|
|
9
12
|
import "./chunk-MAJSPFA6.mjs";
|
|
13
|
+
import {
|
|
14
|
+
isUndefined
|
|
15
|
+
} from "./chunk-VH2PV426.mjs";
|
|
10
16
|
import {
|
|
11
17
|
isNil
|
|
12
18
|
} from "./chunk-OHQAR5AU.mjs";
|
|
@@ -16,10 +22,10 @@ import {
|
|
|
16
22
|
import {
|
|
17
23
|
isNull
|
|
18
24
|
} from "./chunk-AIRSKN47.mjs";
|
|
19
|
-
import {
|
|
20
|
-
isUndefined
|
|
21
|
-
} from "./chunk-VH2PV426.mjs";
|
|
22
25
|
import "./chunk-PMHULJNL.mjs";
|
|
26
|
+
import {
|
|
27
|
+
omit
|
|
28
|
+
} from "./chunk-QZITBKWX.mjs";
|
|
23
29
|
import {
|
|
24
30
|
omitBy
|
|
25
31
|
} from "./chunk-BCTYOXT7.mjs";
|
|
@@ -32,10 +38,10 @@ import {
|
|
|
32
38
|
import {
|
|
33
39
|
invert
|
|
34
40
|
} from "./chunk-74WWMNZS.mjs";
|
|
35
|
-
import {
|
|
36
|
-
omit
|
|
37
|
-
} from "./chunk-QZITBKWX.mjs";
|
|
38
41
|
import "./chunk-TLVQSNOE.mjs";
|
|
42
|
+
import {
|
|
43
|
+
meanBy
|
|
44
|
+
} from "./chunk-IZAD2S7R.mjs";
|
|
39
45
|
import {
|
|
40
46
|
range
|
|
41
47
|
} from "./chunk-DPH2KE6O.mjs";
|
|
@@ -48,35 +54,13 @@ import {
|
|
|
48
54
|
import {
|
|
49
55
|
inRange
|
|
50
56
|
} from "./chunk-BH6HLGBA.mjs";
|
|
51
|
-
import {
|
|
52
|
-
meanBy
|
|
53
|
-
} from "./chunk-IZAD2S7R.mjs";
|
|
54
57
|
import {
|
|
55
58
|
mean
|
|
56
59
|
} from "./chunk-GDC64SYJ.mjs";
|
|
57
60
|
import {
|
|
58
61
|
sum
|
|
59
62
|
} from "./chunk-2SLTL4KL.mjs";
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import {
|
|
62
|
-
noop
|
|
63
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
64
|
-
import {
|
|
65
|
-
once
|
|
66
|
-
} from "./chunk-CMBC4MXG.mjs";
|
|
67
|
-
import {
|
|
68
|
-
throttle
|
|
69
|
-
} from "./chunk-QOJGMVVR.mjs";
|
|
70
|
-
import {
|
|
71
|
-
debounce
|
|
72
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
73
|
-
import "./chunk-NLN3GQ7D.mjs";
|
|
74
|
-
import {
|
|
75
|
-
xor
|
|
76
|
-
} from "./chunk-L7FQX5MN.mjs";
|
|
77
|
-
import {
|
|
78
|
-
xorBy
|
|
79
|
-
} from "./chunk-Q47NGNXT.mjs";
|
|
63
|
+
import "./chunk-OJSIDS6H.mjs";
|
|
80
64
|
import {
|
|
81
65
|
xorWith
|
|
82
66
|
} from "./chunk-QRSJBBFY.mjs";
|
|
@@ -89,18 +73,9 @@ import {
|
|
|
89
73
|
import {
|
|
90
74
|
zipWith
|
|
91
75
|
} from "./chunk-4KYXHZ4R.mjs";
|
|
92
|
-
import {
|
|
93
|
-
unionBy
|
|
94
|
-
} from "./chunk-NFS7RWWE.mjs";
|
|
95
|
-
import {
|
|
96
|
-
unionWith
|
|
97
|
-
} from "./chunk-2ZCITDMK.mjs";
|
|
98
76
|
import {
|
|
99
77
|
uniqBy
|
|
100
78
|
} from "./chunk-OXAZEEGP.mjs";
|
|
101
|
-
import {
|
|
102
|
-
uniqWith
|
|
103
|
-
} from "./chunk-237HGSZS.mjs";
|
|
104
79
|
import {
|
|
105
80
|
unzip
|
|
106
81
|
} from "./chunk-UYZKMBDO.mjs";
|
|
@@ -111,11 +86,11 @@ import {
|
|
|
111
86
|
without
|
|
112
87
|
} from "./chunk-PYEYV7BY.mjs";
|
|
113
88
|
import {
|
|
114
|
-
|
|
115
|
-
} from "./chunk-
|
|
89
|
+
xor
|
|
90
|
+
} from "./chunk-L7FQX5MN.mjs";
|
|
116
91
|
import {
|
|
117
|
-
|
|
118
|
-
} from "./chunk-
|
|
92
|
+
xorBy
|
|
93
|
+
} from "./chunk-Q47NGNXT.mjs";
|
|
119
94
|
import {
|
|
120
95
|
take
|
|
121
96
|
} from "./chunk-ME352XO7.mjs";
|
|
@@ -138,11 +113,14 @@ import {
|
|
|
138
113
|
uniq
|
|
139
114
|
} from "./chunk-DVK2N4KC.mjs";
|
|
140
115
|
import {
|
|
141
|
-
|
|
142
|
-
} from "./chunk-
|
|
116
|
+
unionBy
|
|
117
|
+
} from "./chunk-NFS7RWWE.mjs";
|
|
143
118
|
import {
|
|
144
|
-
|
|
145
|
-
} from "./chunk-
|
|
119
|
+
unionWith
|
|
120
|
+
} from "./chunk-2ZCITDMK.mjs";
|
|
121
|
+
import {
|
|
122
|
+
uniqWith
|
|
123
|
+
} from "./chunk-237HGSZS.mjs";
|
|
146
124
|
import {
|
|
147
125
|
maxBy
|
|
148
126
|
} from "./chunk-OOKNBU4V.mjs";
|
|
@@ -168,11 +146,11 @@ import {
|
|
|
168
146
|
random
|
|
169
147
|
} from "./chunk-SYWMYQYJ.mjs";
|
|
170
148
|
import {
|
|
171
|
-
|
|
172
|
-
} from "./chunk-
|
|
149
|
+
shuffle
|
|
150
|
+
} from "./chunk-G7UQ5PUR.mjs";
|
|
173
151
|
import {
|
|
174
|
-
|
|
175
|
-
} from "./chunk-
|
|
152
|
+
tail
|
|
153
|
+
} from "./chunk-OF6NM4G7.mjs";
|
|
176
154
|
import {
|
|
177
155
|
groupBy
|
|
178
156
|
} from "./chunk-E6E4RZLN.mjs";
|
|
@@ -189,14 +167,11 @@ import {
|
|
|
189
167
|
intersectionWith
|
|
190
168
|
} from "./chunk-XI7KRD2C.mjs";
|
|
191
169
|
import {
|
|
192
|
-
|
|
193
|
-
} from "./chunk-
|
|
194
|
-
import {
|
|
195
|
-
differenceBy
|
|
196
|
-
} from "./chunk-LVWX5B43.mjs";
|
|
170
|
+
keyBy
|
|
171
|
+
} from "./chunk-AJKZMN2V.mjs";
|
|
197
172
|
import {
|
|
198
|
-
|
|
199
|
-
} from "./chunk-
|
|
173
|
+
last
|
|
174
|
+
} from "./chunk-KPBQ7OUY.mjs";
|
|
200
175
|
import {
|
|
201
176
|
drop
|
|
202
177
|
} from "./chunk-S3CORED5.mjs";
|
|
@@ -212,12 +187,15 @@ import {
|
|
|
212
187
|
import {
|
|
213
188
|
fill
|
|
214
189
|
} from "./chunk-C4WE4GLC.mjs";
|
|
215
|
-
import "./chunk-2M3YVRFS.mjs";
|
|
216
|
-
import "./chunk-T5URDZEQ.mjs";
|
|
217
|
-
import "./chunk-FZEZH22H.mjs";
|
|
218
190
|
import {
|
|
219
|
-
|
|
220
|
-
} from "./chunk-
|
|
191
|
+
flattenDeep
|
|
192
|
+
} from "./chunk-HJPB4KC3.mjs";
|
|
193
|
+
import {
|
|
194
|
+
flatten
|
|
195
|
+
} from "./chunk-33MSBDC6.mjs";
|
|
196
|
+
import {
|
|
197
|
+
forEachRight
|
|
198
|
+
} from "./chunk-IEA53J7P.mjs";
|
|
221
199
|
import {
|
|
222
200
|
chunk
|
|
223
201
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -227,9 +205,38 @@ import {
|
|
|
227
205
|
import {
|
|
228
206
|
countBy
|
|
229
207
|
} from "./chunk-CRSKT4WW.mjs";
|
|
208
|
+
import {
|
|
209
|
+
difference
|
|
210
|
+
} from "./chunk-JPUKH67K.mjs";
|
|
211
|
+
import {
|
|
212
|
+
differenceBy
|
|
213
|
+
} from "./chunk-LVWX5B43.mjs";
|
|
214
|
+
import {
|
|
215
|
+
differenceWith
|
|
216
|
+
} from "./chunk-6NVQAHXP.mjs";
|
|
217
|
+
import "./chunk-2M3YVRFS.mjs";
|
|
218
|
+
import "./chunk-T5URDZEQ.mjs";
|
|
219
|
+
import "./chunk-FZEZH22H.mjs";
|
|
220
|
+
import {
|
|
221
|
+
AbortError
|
|
222
|
+
} from "./chunk-DXB7EZUQ.mjs";
|
|
223
|
+
import "./chunk-N6EM6ETS.mjs";
|
|
224
|
+
import {
|
|
225
|
+
once
|
|
226
|
+
} from "./chunk-CMBC4MXG.mjs";
|
|
227
|
+
import {
|
|
228
|
+
throttle
|
|
229
|
+
} from "./chunk-QOJGMVVR.mjs";
|
|
230
|
+
import {
|
|
231
|
+
debounce
|
|
232
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
233
|
+
import {
|
|
234
|
+
noop
|
|
235
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
230
236
|
import "./chunk-2MM5EJJX.mjs";
|
|
231
237
|
export {
|
|
232
238
|
AbortError,
|
|
239
|
+
capitalize,
|
|
233
240
|
chunk,
|
|
234
241
|
clamp,
|
|
235
242
|
compact,
|
|
@@ -245,6 +252,7 @@ export {
|
|
|
245
252
|
dropWhile,
|
|
246
253
|
fill,
|
|
247
254
|
flatten,
|
|
255
|
+
flattenDeep,
|
|
248
256
|
forEachRight,
|
|
249
257
|
groupBy,
|
|
250
258
|
head,
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-TLVQSNOE.mjs";
|
|
2
|
+
import {
|
|
3
|
+
meanBy
|
|
4
|
+
} from "../chunk-IZAD2S7R.mjs";
|
|
2
5
|
import {
|
|
3
6
|
range
|
|
4
7
|
} from "../chunk-DPH2KE6O.mjs";
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
inRange
|
|
13
16
|
} from "../chunk-BH6HLGBA.mjs";
|
|
14
|
-
import {
|
|
15
|
-
meanBy
|
|
16
|
-
} from "../chunk-IZAD2S7R.mjs";
|
|
17
17
|
import {
|
|
18
18
|
mean
|
|
19
19
|
} from "../chunk-GDC64SYJ.mjs";
|
package/dist/object/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-PMHULJNL.mjs";
|
|
2
|
+
import {
|
|
3
|
+
omit
|
|
4
|
+
} from "../chunk-QZITBKWX.mjs";
|
|
2
5
|
import {
|
|
3
6
|
omitBy
|
|
4
7
|
} from "../chunk-BCTYOXT7.mjs";
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
invert
|
|
13
16
|
} from "../chunk-74WWMNZS.mjs";
|
|
14
|
-
import {
|
|
15
|
-
omit
|
|
16
|
-
} from "../chunk-QZITBKWX.mjs";
|
|
17
17
|
import "../chunk-2MM5EJJX.mjs";
|
|
18
18
|
export {
|
|
19
19
|
invert,
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-MAJSPFA6.mjs";
|
|
2
|
+
import {
|
|
3
|
+
isUndefined
|
|
4
|
+
} from "../chunk-VH2PV426.mjs";
|
|
2
5
|
import {
|
|
3
6
|
isNil
|
|
4
7
|
} from "../chunk-OHQAR5AU.mjs";
|
|
@@ -8,9 +11,6 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
isNull
|
|
10
13
|
} from "../chunk-AIRSKN47.mjs";
|
|
11
|
-
import {
|
|
12
|
-
isUndefined
|
|
13
|
-
} from "../chunk-VH2PV426.mjs";
|
|
14
14
|
import "../chunk-2MM5EJJX.mjs";
|
|
15
15
|
export {
|
|
16
16
|
isNil,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts the first character of string to upper case and the remaining to lower case.
|
|
3
|
+
*
|
|
4
|
+
* @template T - Literal type of the string.
|
|
5
|
+
* @param {T} str - The string to be converted to uppercase.
|
|
6
|
+
* @returns {Capitalize<T>} - The capitalized string.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = capitalize('fred') // returns 'Fred'
|
|
10
|
+
* const result2 = capitalize('FRED') // returns 'Fred'
|
|
11
|
+
*/
|
|
12
|
+
declare const capitalize: <T extends string>(str: T) => Capitalize<T>;
|
|
13
|
+
|
|
14
|
+
export { capitalize };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts the first character of string to upper case and the remaining to lower case.
|
|
3
|
+
*
|
|
4
|
+
* @template T - Literal type of the string.
|
|
5
|
+
* @param {T} str - The string to be converted to uppercase.
|
|
6
|
+
* @returns {Capitalize<T>} - The capitalized string.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = capitalize('fred') // returns 'Fred'
|
|
10
|
+
* const result2 = capitalize('FRED') // returns 'Fred'
|
|
11
|
+
*/
|
|
12
|
+
declare const capitalize: <T extends string>(str: T) => Capitalize<T>;
|
|
13
|
+
|
|
14
|
+
export { capitalize };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/string/capitalize.ts
|
|
21
|
+
var capitalize_exports = {};
|
|
22
|
+
__export(capitalize_exports, {
|
|
23
|
+
capitalize: () => capitalize
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(capitalize_exports);
|
|
26
|
+
var capitalize = (str) => {
|
|
27
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
capitalize
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=capitalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/string/capitalize.ts"],"sourcesContent":["/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/string/index.d.mts
CHANGED
package/dist/string/index.d.ts
CHANGED
package/dist/string/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/string/index.ts
|
|
21
21
|
var string_exports = {};
|
|
22
22
|
__export(string_exports, {
|
|
23
|
+
capitalize: () => capitalize,
|
|
23
24
|
snakeCase: () => snakeCase
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(string_exports);
|
|
@@ -32,8 +33,14 @@ var snakeCase = (str) => {
|
|
|
32
33
|
const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
|
|
33
34
|
return splitWords.map((word) => word.toLowerCase()).join("_");
|
|
34
35
|
};
|
|
36
|
+
|
|
37
|
+
// src/string/capitalize.ts
|
|
38
|
+
var capitalize = (str) => {
|
|
39
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
40
|
+
};
|
|
35
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
42
|
0 && (module.exports = {
|
|
43
|
+
capitalize,
|
|
37
44
|
snakeCase
|
|
38
45
|
});
|
|
39
46
|
//# sourceMappingURL=index.js.map
|
package/dist/string/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/string/index.ts","../../src/constants/caseSplitPattern.ts","../../src/string/snakeCase.ts"],"sourcesContent":["export { snakeCase } from './snakeCase.ts';\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\n\nexport const CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;\n","import { CASE_SPLIT_PATTERN } from '../constants';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const splitWords = str.match(CASE_SPLIT_PATTERN) || [];\n return splitWords.map(word => word.toLowerCase()).join('_');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,qBAAqB;;;ACA3B,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,aAAa,IAAI,MAAM,kBAAkB,KAAK,CAAC;AACrD,SAAO,WAAW,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AAC5D;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/string/index.ts","../../src/constants/caseSplitPattern.ts","../../src/string/snakeCase.ts","../../src/string/capitalize.ts"],"sourcesContent":["export { snakeCase } from './snakeCase.ts';\nexport { capitalize } from './capitalize.ts';\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\n\nexport const CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;\n","import { CASE_SPLIT_PATTERN } from '../constants';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const splitWords = str.match(CASE_SPLIT_PATTERN) || [];\n return splitWords.map(word => word.toLowerCase()).join('_');\n};\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,qBAAqB;;;ACA3B,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,aAAa,IAAI,MAAM,kBAAkB,KAAK,CAAC;AACrD,SAAO,WAAW,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AAC5D;;;ACRO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;","names":[]}
|
package/dist/string/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-MPBVTIU3.mjs";
|
|
2
|
+
import {
|
|
3
|
+
capitalize
|
|
4
|
+
} from "../chunk-U56ZOM7L.mjs";
|
|
2
5
|
import {
|
|
3
6
|
snakeCase
|
|
4
7
|
} from "../chunk-VRFIBW4H.mjs";
|
|
@@ -6,6 +9,7 @@ import "../chunk-2M3YVRFS.mjs";
|
|
|
6
9
|
import "../chunk-T5URDZEQ.mjs";
|
|
7
10
|
import "../chunk-2MM5EJJX.mjs";
|
|
8
11
|
export {
|
|
12
|
+
capitalize,
|
|
9
13
|
snakeCase
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=index.mjs.map
|
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.9.0-dev.
|
|
4
|
+
"version": "1.9.0-dev.179+16d326c4",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
package/dist/chunk-NLN3GQ7D.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-NLN3GQ7D.mjs.map
|
package/dist/chunk-YOFIBRET.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-YOFIBRET.mjs.map
|
|
File without changes
|
|
File without changes
|