es-toolkit 1.9.0-dev.173 → 1.9.0-dev.174
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/index.mjs +26 -26
- package/dist/chunk-2M3YVRFS.mjs +1 -0
- package/dist/chunk-2M3YVRFS.mjs.map +1 -0
- package/dist/chunk-T5URDZEQ.mjs +7 -0
- package/dist/chunk-T5URDZEQ.mjs.map +1 -0
- package/dist/chunk-VRFIBW4H.mjs +14 -0
- package/dist/chunk-VRFIBW4H.mjs.map +1 -0
- package/dist/chunk-YOFIBRET.mjs +1 -0
- package/dist/chunk-YOFIBRET.mjs.map +1 -0
- package/dist/constants/caseSplitPattern.d.mts +19 -0
- package/dist/constants/caseSplitPattern.d.ts +19 -0
- package/dist/constants/caseSplitPattern.js +31 -0
- package/dist/constants/caseSplitPattern.js.map +1 -0
- package/dist/constants/caseSplitPattern.mjs +8 -0
- package/dist/constants/caseSplitPattern.mjs.map +1 -0
- package/dist/constants/index.d.mts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +33 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/index.mjs +9 -0
- package/dist/constants/index.mjs.map +1 -0
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -42
- package/dist/math/index.mjs +3 -3
- package/dist/object/index.mjs +6 -6
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +39 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +11 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/snakeCase.d.mts +17 -0
- package/dist/string/snakeCase.d.ts +17 -0
- package/dist/string/snakeCase.js +39 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/snakeCase.mjs +10 -0
- package/dist/string/snakeCase.mjs.map +1 -0
- package/package.json +21 -1
- package/string.d.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import "./chunk-ARZ5BDR6.mjs";
|
|
2
|
+
import "./chunk-YOFIBRET.mjs";
|
|
3
|
+
import {
|
|
4
|
+
snakeCase
|
|
5
|
+
} from "./chunk-VRFIBW4H.mjs";
|
|
1
6
|
import "./chunk-MAJSPFA6.mjs";
|
|
2
7
|
import {
|
|
3
8
|
isNil
|
|
@@ -11,11 +16,16 @@ import {
|
|
|
11
16
|
import {
|
|
12
17
|
isUndefined
|
|
13
18
|
} from "./chunk-VH2PV426.mjs";
|
|
14
|
-
import "./chunk-ARZ5BDR6.mjs";
|
|
15
19
|
import {
|
|
16
20
|
delay
|
|
17
21
|
} from "./chunk-O64NE2P4.mjs";
|
|
18
22
|
import "./chunk-PMHULJNL.mjs";
|
|
23
|
+
import {
|
|
24
|
+
pick
|
|
25
|
+
} from "./chunk-HPFDYUGP.mjs";
|
|
26
|
+
import {
|
|
27
|
+
pickBy
|
|
28
|
+
} from "./chunk-6CLH5YZ2.mjs";
|
|
19
29
|
import {
|
|
20
30
|
invert
|
|
21
31
|
} from "./chunk-74WWMNZS.mjs";
|
|
@@ -25,13 +35,10 @@ import {
|
|
|
25
35
|
import {
|
|
26
36
|
omitBy
|
|
27
37
|
} from "./chunk-BCTYOXT7.mjs";
|
|
28
|
-
import {
|
|
29
|
-
pick
|
|
30
|
-
} from "./chunk-HPFDYUGP.mjs";
|
|
31
|
-
import {
|
|
32
|
-
pickBy
|
|
33
|
-
} from "./chunk-6CLH5YZ2.mjs";
|
|
34
38
|
import "./chunk-TLVQSNOE.mjs";
|
|
39
|
+
import {
|
|
40
|
+
range
|
|
41
|
+
} from "./chunk-DPH2KE6O.mjs";
|
|
35
42
|
import {
|
|
36
43
|
round
|
|
37
44
|
} from "./chunk-5PMKOZ2F.mjs";
|
|
@@ -50,10 +57,16 @@ import {
|
|
|
50
57
|
import {
|
|
51
58
|
sum
|
|
52
59
|
} from "./chunk-NOFHNJ5C.mjs";
|
|
53
|
-
import {
|
|
54
|
-
range
|
|
55
|
-
} from "./chunk-DPH2KE6O.mjs";
|
|
56
60
|
import "./chunk-WGIVYA3P.mjs";
|
|
61
|
+
import {
|
|
62
|
+
zipObject
|
|
63
|
+
} from "./chunk-6GWEY5EL.mjs";
|
|
64
|
+
import {
|
|
65
|
+
zipWith
|
|
66
|
+
} from "./chunk-4KYXHZ4R.mjs";
|
|
67
|
+
import {
|
|
68
|
+
unzip
|
|
69
|
+
} from "./chunk-UYZKMBDO.mjs";
|
|
57
70
|
import {
|
|
58
71
|
unzipWith
|
|
59
72
|
} from "./chunk-IFNXROZR.mjs";
|
|
@@ -73,11 +86,11 @@ import {
|
|
|
73
86
|
zip
|
|
74
87
|
} from "./chunk-IDCUZVJL.mjs";
|
|
75
88
|
import {
|
|
76
|
-
|
|
77
|
-
} from "./chunk-
|
|
89
|
+
takeRight
|
|
90
|
+
} from "./chunk-IQLKIDXF.mjs";
|
|
78
91
|
import {
|
|
79
|
-
|
|
80
|
-
} from "./chunk-
|
|
92
|
+
takeRightWhile
|
|
93
|
+
} from "./chunk-NTLX2MPV.mjs";
|
|
81
94
|
import {
|
|
82
95
|
takeWhile
|
|
83
96
|
} from "./chunk-2IXFGSUA.mjs";
|
|
@@ -90,6 +103,9 @@ import {
|
|
|
90
103
|
import {
|
|
91
104
|
unionWith
|
|
92
105
|
} from "./chunk-2ZCITDMK.mjs";
|
|
106
|
+
import {
|
|
107
|
+
uniqWith
|
|
108
|
+
} from "./chunk-237HGSZS.mjs";
|
|
93
109
|
import {
|
|
94
110
|
uniq
|
|
95
111
|
} from "./chunk-DVK2N4KC.mjs";
|
|
@@ -97,11 +113,11 @@ import {
|
|
|
97
113
|
uniqBy
|
|
98
114
|
} from "./chunk-OXAZEEGP.mjs";
|
|
99
115
|
import {
|
|
100
|
-
|
|
101
|
-
} from "./chunk-
|
|
116
|
+
minBy
|
|
117
|
+
} from "./chunk-IJD7FE2Z.mjs";
|
|
102
118
|
import {
|
|
103
|
-
|
|
104
|
-
} from "./chunk-
|
|
119
|
+
orderBy
|
|
120
|
+
} from "./chunk-7B7W36UP.mjs";
|
|
105
121
|
import {
|
|
106
122
|
partition
|
|
107
123
|
} from "./chunk-DN3NOZ3H.mjs";
|
|
@@ -127,11 +143,8 @@ import {
|
|
|
127
143
|
take
|
|
128
144
|
} from "./chunk-ME352XO7.mjs";
|
|
129
145
|
import {
|
|
130
|
-
|
|
131
|
-
} from "./chunk-
|
|
132
|
-
import {
|
|
133
|
-
takeRightWhile
|
|
134
|
-
} from "./chunk-NTLX2MPV.mjs";
|
|
146
|
+
head
|
|
147
|
+
} from "./chunk-HM2JT2RX.mjs";
|
|
135
148
|
import {
|
|
136
149
|
intersection
|
|
137
150
|
} from "./chunk-FVVSE2F2.mjs";
|
|
@@ -151,11 +164,11 @@ import {
|
|
|
151
164
|
maxBy
|
|
152
165
|
} from "./chunk-OOKNBU4V.mjs";
|
|
153
166
|
import {
|
|
154
|
-
|
|
155
|
-
} from "./chunk-
|
|
167
|
+
drop
|
|
168
|
+
} from "./chunk-S3CORED5.mjs";
|
|
156
169
|
import {
|
|
157
|
-
|
|
158
|
-
} from "./chunk-
|
|
170
|
+
dropRight
|
|
171
|
+
} from "./chunk-JEKUA56R.mjs";
|
|
159
172
|
import {
|
|
160
173
|
dropRightWhile
|
|
161
174
|
} from "./chunk-JE6JKZU3.mjs";
|
|
@@ -174,9 +187,6 @@ import {
|
|
|
174
187
|
import {
|
|
175
188
|
groupBy
|
|
176
189
|
} from "./chunk-E6E4RZLN.mjs";
|
|
177
|
-
import {
|
|
178
|
-
head
|
|
179
|
-
} from "./chunk-HM2JT2RX.mjs";
|
|
180
190
|
import {
|
|
181
191
|
chunk
|
|
182
192
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -195,29 +205,25 @@ import {
|
|
|
195
205
|
import {
|
|
196
206
|
differenceWith
|
|
197
207
|
} from "./chunk-6NVQAHXP.mjs";
|
|
198
|
-
import
|
|
199
|
-
|
|
200
|
-
} from "./chunk-S3CORED5.mjs";
|
|
201
|
-
import {
|
|
202
|
-
dropRight
|
|
203
|
-
} from "./chunk-JEKUA56R.mjs";
|
|
208
|
+
import "./chunk-2M3YVRFS.mjs";
|
|
209
|
+
import "./chunk-T5URDZEQ.mjs";
|
|
204
210
|
import "./chunk-FZEZH22H.mjs";
|
|
205
211
|
import {
|
|
206
212
|
AbortError
|
|
207
213
|
} from "./chunk-DXB7EZUQ.mjs";
|
|
208
214
|
import "./chunk-N6EM6ETS.mjs";
|
|
209
|
-
import {
|
|
210
|
-
debounce
|
|
211
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
212
|
-
import {
|
|
213
|
-
noop
|
|
214
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
215
215
|
import {
|
|
216
216
|
once
|
|
217
217
|
} from "./chunk-CMBC4MXG.mjs";
|
|
218
218
|
import {
|
|
219
219
|
throttle
|
|
220
220
|
} from "./chunk-QOJGMVVR.mjs";
|
|
221
|
+
import {
|
|
222
|
+
debounce
|
|
223
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
224
|
+
import {
|
|
225
|
+
noop
|
|
226
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
221
227
|
import "./chunk-2MM5EJJX.mjs";
|
|
222
228
|
export {
|
|
223
229
|
AbortError,
|
|
@@ -269,6 +275,7 @@ export {
|
|
|
269
275
|
sample,
|
|
270
276
|
sampleSize,
|
|
271
277
|
shuffle,
|
|
278
|
+
snakeCase,
|
|
272
279
|
sum,
|
|
273
280
|
tail,
|
|
274
281
|
take,
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-TLVQSNOE.mjs";
|
|
2
|
+
import {
|
|
3
|
+
range
|
|
4
|
+
} from "../chunk-DPH2KE6O.mjs";
|
|
2
5
|
import {
|
|
3
6
|
round
|
|
4
7
|
} from "../chunk-5PMKOZ2F.mjs";
|
|
@@ -17,9 +20,6 @@ import {
|
|
|
17
20
|
import {
|
|
18
21
|
sum
|
|
19
22
|
} from "../chunk-NOFHNJ5C.mjs";
|
|
20
|
-
import {
|
|
21
|
-
range
|
|
22
|
-
} from "../chunk-DPH2KE6O.mjs";
|
|
23
23
|
import {
|
|
24
24
|
randomInt
|
|
25
25
|
} from "../chunk-GIWAOOFY.mjs";
|
package/dist/object/index.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import "../chunk-PMHULJNL.mjs";
|
|
2
|
+
import {
|
|
3
|
+
pick
|
|
4
|
+
} from "../chunk-HPFDYUGP.mjs";
|
|
5
|
+
import {
|
|
6
|
+
pickBy
|
|
7
|
+
} from "../chunk-6CLH5YZ2.mjs";
|
|
2
8
|
import {
|
|
3
9
|
invert
|
|
4
10
|
} from "../chunk-74WWMNZS.mjs";
|
|
@@ -8,12 +14,6 @@ import {
|
|
|
8
14
|
import {
|
|
9
15
|
omitBy
|
|
10
16
|
} from "../chunk-BCTYOXT7.mjs";
|
|
11
|
-
import {
|
|
12
|
-
pick
|
|
13
|
-
} from "../chunk-HPFDYUGP.mjs";
|
|
14
|
-
import {
|
|
15
|
-
pickBy
|
|
16
|
-
} from "../chunk-6CLH5YZ2.mjs";
|
|
17
17
|
import "../chunk-2MM5EJJX.mjs";
|
|
18
18
|
export {
|
|
19
19
|
invert,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { snakeCase } from './snakeCase.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { snakeCase } from './snakeCase.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
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/index.ts
|
|
21
|
+
var string_exports = {};
|
|
22
|
+
__export(string_exports, {
|
|
23
|
+
snakeCase: () => snakeCase
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(string_exports);
|
|
26
|
+
|
|
27
|
+
// src/constants/caseSplitPattern.ts
|
|
28
|
+
var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
|
29
|
+
|
|
30
|
+
// src/string/snakeCase.ts
|
|
31
|
+
var snakeCase = (str) => {
|
|
32
|
+
const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
|
|
33
|
+
return splitWords.map((word) => word.toLowerCase()).join("_");
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
snakeCase
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to snake case.
|
|
3
|
+
*
|
|
4
|
+
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} str - The string that is to be changed to snake case.
|
|
7
|
+
* @returns {string} - The converted string to snake case.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
|
|
11
|
+
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
|
|
12
|
+
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
|
|
13
|
+
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
|
|
14
|
+
*/
|
|
15
|
+
declare const snakeCase: (str: string) => string;
|
|
16
|
+
|
|
17
|
+
export { snakeCase };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to snake case.
|
|
3
|
+
*
|
|
4
|
+
* Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} str - The string that is to be changed to snake case.
|
|
7
|
+
* @returns {string} - The converted string to snake case.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'
|
|
11
|
+
* const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'
|
|
12
|
+
* const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'
|
|
13
|
+
* const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'
|
|
14
|
+
*/
|
|
15
|
+
declare const snakeCase: (str: string) => string;
|
|
16
|
+
|
|
17
|
+
export { snakeCase };
|
|
@@ -0,0 +1,39 @@
|
|
|
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/snakeCase.ts
|
|
21
|
+
var snakeCase_exports = {};
|
|
22
|
+
__export(snakeCase_exports, {
|
|
23
|
+
snakeCase: () => snakeCase
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(snakeCase_exports);
|
|
26
|
+
|
|
27
|
+
// src/constants/caseSplitPattern.ts
|
|
28
|
+
var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
|
29
|
+
|
|
30
|
+
// src/string/snakeCase.ts
|
|
31
|
+
var snakeCase = (str) => {
|
|
32
|
+
const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
|
|
33
|
+
return splitWords.map((word) => word.toLowerCase()).join("_");
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
snakeCase
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=snakeCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/string/snakeCase.ts","../../src/constants/caseSplitPattern.ts"],"sourcesContent":["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 * 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,qBAAqB;;;ADA3B,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
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.174+d48900fa",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -84,6 +84,16 @@
|
|
|
84
84
|
"default": "./dist/promise/index.js"
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
+
"./string": {
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./dist/string/index.d.mts",
|
|
90
|
+
"default": "./dist/string/index.mjs"
|
|
91
|
+
},
|
|
92
|
+
"require": {
|
|
93
|
+
"types": "./dist/string/index.d.ts",
|
|
94
|
+
"default": "./dist/string/index.js"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
87
97
|
"./package.json": "./package.json"
|
|
88
98
|
},
|
|
89
99
|
"files": [
|
|
@@ -166,6 +176,16 @@
|
|
|
166
176
|
"default": "./dist/promise/index.js"
|
|
167
177
|
}
|
|
168
178
|
},
|
|
179
|
+
"./string": {
|
|
180
|
+
"import": {
|
|
181
|
+
"types": "./dist/string/index.d.mts",
|
|
182
|
+
"default": "./dist/string/index.mjs"
|
|
183
|
+
},
|
|
184
|
+
"require": {
|
|
185
|
+
"types": "./dist/string/index.d.ts",
|
|
186
|
+
"default": "./dist/string/index.js"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
169
189
|
"./package.json": "./package.json"
|
|
170
190
|
}
|
|
171
191
|
},
|
package/string.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/string';
|