es-toolkit 1.9.0-dev.173 → 1.9.0-dev.175
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.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +14 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +37 -33
- package/dist/array/toFilled.d.mts +33 -0
- package/dist/array/toFilled.d.ts +33 -0
- package/dist/array/toFilled.js +40 -0
- package/dist/array/toFilled.js.map +1 -0
- package/dist/array/toFilled.mjs +8 -0
- package/dist/chunk-2M3YVRFS.mjs +1 -0
- package/dist/chunk-2M3YVRFS.mjs.map +1 -0
- package/dist/chunk-NLN3GQ7D.mjs +1 -0
- package/dist/chunk-NLN3GQ7D.mjs.map +1 -0
- package/dist/chunk-OP4OAKQJ.mjs +16 -0
- package/dist/chunk-OP4OAKQJ.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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -51
- 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/chunk-WGIVYA3P.mjs +0 -1
- /package/dist/{chunk-WGIVYA3P.mjs.map → array/toFilled.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import "./chunk-ARZ5BDR6.mjs";
|
|
2
|
+
import {
|
|
3
|
+
delay
|
|
4
|
+
} from "./chunk-O64NE2P4.mjs";
|
|
5
|
+
import "./chunk-YOFIBRET.mjs";
|
|
6
|
+
import {
|
|
7
|
+
snakeCase
|
|
8
|
+
} from "./chunk-VRFIBW4H.mjs";
|
|
1
9
|
import "./chunk-MAJSPFA6.mjs";
|
|
2
10
|
import {
|
|
3
11
|
isNil
|
|
@@ -11,17 +19,7 @@ import {
|
|
|
11
19
|
import {
|
|
12
20
|
isUndefined
|
|
13
21
|
} from "./chunk-VH2PV426.mjs";
|
|
14
|
-
import "./chunk-ARZ5BDR6.mjs";
|
|
15
|
-
import {
|
|
16
|
-
delay
|
|
17
|
-
} from "./chunk-O64NE2P4.mjs";
|
|
18
22
|
import "./chunk-PMHULJNL.mjs";
|
|
19
|
-
import {
|
|
20
|
-
invert
|
|
21
|
-
} from "./chunk-74WWMNZS.mjs";
|
|
22
|
-
import {
|
|
23
|
-
omit
|
|
24
|
-
} from "./chunk-QZITBKWX.mjs";
|
|
25
23
|
import {
|
|
26
24
|
omitBy
|
|
27
25
|
} from "./chunk-BCTYOXT7.mjs";
|
|
@@ -31,7 +29,16 @@ import {
|
|
|
31
29
|
import {
|
|
32
30
|
pickBy
|
|
33
31
|
} from "./chunk-6CLH5YZ2.mjs";
|
|
32
|
+
import {
|
|
33
|
+
invert
|
|
34
|
+
} from "./chunk-74WWMNZS.mjs";
|
|
35
|
+
import {
|
|
36
|
+
omit
|
|
37
|
+
} from "./chunk-QZITBKWX.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,22 @@ import {
|
|
|
50
57
|
import {
|
|
51
58
|
sum
|
|
52
59
|
} from "./chunk-NOFHNJ5C.mjs";
|
|
60
|
+
import "./chunk-NLN3GQ7D.mjs";
|
|
53
61
|
import {
|
|
54
|
-
|
|
55
|
-
} from "./chunk-
|
|
56
|
-
import
|
|
62
|
+
zip
|
|
63
|
+
} from "./chunk-IDCUZVJL.mjs";
|
|
64
|
+
import {
|
|
65
|
+
zipObject
|
|
66
|
+
} from "./chunk-6GWEY5EL.mjs";
|
|
67
|
+
import {
|
|
68
|
+
zipWith
|
|
69
|
+
} from "./chunk-4KYXHZ4R.mjs";
|
|
70
|
+
import {
|
|
71
|
+
uniqBy
|
|
72
|
+
} from "./chunk-OXAZEEGP.mjs";
|
|
73
|
+
import {
|
|
74
|
+
unzip
|
|
75
|
+
} from "./chunk-UYZKMBDO.mjs";
|
|
57
76
|
import {
|
|
58
77
|
unzipWith
|
|
59
78
|
} from "./chunk-IFNXROZR.mjs";
|
|
@@ -70,17 +89,17 @@ import {
|
|
|
70
89
|
xorWith
|
|
71
90
|
} from "./chunk-QRSJBBFY.mjs";
|
|
72
91
|
import {
|
|
73
|
-
|
|
74
|
-
} from "./chunk-
|
|
75
|
-
import {
|
|
76
|
-
zipObject
|
|
77
|
-
} from "./chunk-6GWEY5EL.mjs";
|
|
92
|
+
takeRight
|
|
93
|
+
} from "./chunk-IQLKIDXF.mjs";
|
|
78
94
|
import {
|
|
79
|
-
|
|
80
|
-
} from "./chunk-
|
|
95
|
+
takeRightWhile
|
|
96
|
+
} from "./chunk-NTLX2MPV.mjs";
|
|
81
97
|
import {
|
|
82
98
|
takeWhile
|
|
83
99
|
} from "./chunk-2IXFGSUA.mjs";
|
|
100
|
+
import {
|
|
101
|
+
toFilled
|
|
102
|
+
} from "./chunk-OP4OAKQJ.mjs";
|
|
84
103
|
import {
|
|
85
104
|
union
|
|
86
105
|
} from "./chunk-R6QA7PLZ.mjs";
|
|
@@ -90,18 +109,18 @@ import {
|
|
|
90
109
|
import {
|
|
91
110
|
unionWith
|
|
92
111
|
} from "./chunk-2ZCITDMK.mjs";
|
|
112
|
+
import {
|
|
113
|
+
uniqWith
|
|
114
|
+
} from "./chunk-237HGSZS.mjs";
|
|
93
115
|
import {
|
|
94
116
|
uniq
|
|
95
117
|
} from "./chunk-DVK2N4KC.mjs";
|
|
96
118
|
import {
|
|
97
|
-
|
|
98
|
-
} from "./chunk-
|
|
99
|
-
import {
|
|
100
|
-
uniqWith
|
|
101
|
-
} from "./chunk-237HGSZS.mjs";
|
|
119
|
+
minBy
|
|
120
|
+
} from "./chunk-IJD7FE2Z.mjs";
|
|
102
121
|
import {
|
|
103
|
-
|
|
104
|
-
} from "./chunk-
|
|
122
|
+
orderBy
|
|
123
|
+
} from "./chunk-7B7W36UP.mjs";
|
|
105
124
|
import {
|
|
106
125
|
partition
|
|
107
126
|
} from "./chunk-DN3NOZ3H.mjs";
|
|
@@ -127,11 +146,8 @@ import {
|
|
|
127
146
|
take
|
|
128
147
|
} from "./chunk-ME352XO7.mjs";
|
|
129
148
|
import {
|
|
130
|
-
|
|
131
|
-
} from "./chunk-
|
|
132
|
-
import {
|
|
133
|
-
takeRightWhile
|
|
134
|
-
} from "./chunk-NTLX2MPV.mjs";
|
|
149
|
+
head
|
|
150
|
+
} from "./chunk-HM2JT2RX.mjs";
|
|
135
151
|
import {
|
|
136
152
|
intersection
|
|
137
153
|
} from "./chunk-FVVSE2F2.mjs";
|
|
@@ -151,11 +167,11 @@ import {
|
|
|
151
167
|
maxBy
|
|
152
168
|
} from "./chunk-OOKNBU4V.mjs";
|
|
153
169
|
import {
|
|
154
|
-
|
|
155
|
-
} from "./chunk-
|
|
170
|
+
drop
|
|
171
|
+
} from "./chunk-S3CORED5.mjs";
|
|
156
172
|
import {
|
|
157
|
-
|
|
158
|
-
} from "./chunk-
|
|
173
|
+
dropRight
|
|
174
|
+
} from "./chunk-JEKUA56R.mjs";
|
|
159
175
|
import {
|
|
160
176
|
dropRightWhile
|
|
161
177
|
} from "./chunk-JE6JKZU3.mjs";
|
|
@@ -174,9 +190,6 @@ import {
|
|
|
174
190
|
import {
|
|
175
191
|
groupBy
|
|
176
192
|
} from "./chunk-E6E4RZLN.mjs";
|
|
177
|
-
import {
|
|
178
|
-
head
|
|
179
|
-
} from "./chunk-HM2JT2RX.mjs";
|
|
180
193
|
import {
|
|
181
194
|
chunk
|
|
182
195
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -195,29 +208,25 @@ import {
|
|
|
195
208
|
import {
|
|
196
209
|
differenceWith
|
|
197
210
|
} from "./chunk-6NVQAHXP.mjs";
|
|
198
|
-
import {
|
|
199
|
-
drop
|
|
200
|
-
} from "./chunk-S3CORED5.mjs";
|
|
201
|
-
import {
|
|
202
|
-
dropRight
|
|
203
|
-
} from "./chunk-JEKUA56R.mjs";
|
|
204
211
|
import "./chunk-FZEZH22H.mjs";
|
|
205
212
|
import {
|
|
206
213
|
AbortError
|
|
207
214
|
} from "./chunk-DXB7EZUQ.mjs";
|
|
215
|
+
import "./chunk-2M3YVRFS.mjs";
|
|
216
|
+
import "./chunk-T5URDZEQ.mjs";
|
|
208
217
|
import "./chunk-N6EM6ETS.mjs";
|
|
209
|
-
import {
|
|
210
|
-
debounce
|
|
211
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
212
|
-
import {
|
|
213
|
-
noop
|
|
214
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
215
218
|
import {
|
|
216
219
|
once
|
|
217
220
|
} from "./chunk-CMBC4MXG.mjs";
|
|
218
221
|
import {
|
|
219
222
|
throttle
|
|
220
223
|
} from "./chunk-QOJGMVVR.mjs";
|
|
224
|
+
import {
|
|
225
|
+
debounce
|
|
226
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
227
|
+
import {
|
|
228
|
+
noop
|
|
229
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
221
230
|
import "./chunk-2MM5EJJX.mjs";
|
|
222
231
|
export {
|
|
223
232
|
AbortError,
|
|
@@ -269,6 +278,7 @@ export {
|
|
|
269
278
|
sample,
|
|
270
279
|
sampleSize,
|
|
271
280
|
shuffle,
|
|
281
|
+
snakeCase,
|
|
272
282
|
sum,
|
|
273
283
|
tail,
|
|
274
284
|
take,
|
|
@@ -276,6 +286,7 @@ export {
|
|
|
276
286
|
takeRightWhile,
|
|
277
287
|
takeWhile,
|
|
278
288
|
throttle,
|
|
289
|
+
toFilled,
|
|
279
290
|
union,
|
|
280
291
|
unionBy,
|
|
281
292
|
unionWith,
|
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,10 +1,4 @@
|
|
|
1
1
|
import "../chunk-PMHULJNL.mjs";
|
|
2
|
-
import {
|
|
3
|
-
invert
|
|
4
|
-
} from "../chunk-74WWMNZS.mjs";
|
|
5
|
-
import {
|
|
6
|
-
omit
|
|
7
|
-
} from "../chunk-QZITBKWX.mjs";
|
|
8
2
|
import {
|
|
9
3
|
omitBy
|
|
10
4
|
} from "../chunk-BCTYOXT7.mjs";
|
|
@@ -14,6 +8,12 @@ import {
|
|
|
14
8
|
import {
|
|
15
9
|
pickBy
|
|
16
10
|
} from "../chunk-6CLH5YZ2.mjs";
|
|
11
|
+
import {
|
|
12
|
+
invert
|
|
13
|
+
} 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,
|
|
@@ -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.175+ea66835f",
|
|
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';
|
package/dist/chunk-WGIVYA3P.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-WGIVYA3P.mjs.map
|
|
File without changes
|