es-toolkit 1.9.0-dev.172 → 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.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 +17 -13
- package/dist/array/last.d.mts +25 -0
- package/dist/array/last.d.ts +25 -0
- package/dist/array/last.js +33 -0
- package/dist/array/last.js.map +1 -0
- package/dist/array/last.mjs +8 -0
- package/dist/chunk-2M3YVRFS.mjs +1 -0
- package/dist/chunk-2M3YVRFS.mjs.map +1 -0
- package/dist/chunk-KPBQ7OUY.mjs +9 -0
- package/dist/chunk-KPBQ7OUY.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-WGIVYA3P.mjs +1 -0
- package/dist/chunk-WGIVYA3P.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 +18 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -58
- 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-LOY6PATI.mjs +0 -1
- /package/dist/{chunk-LOY6PATI.mjs.map → array/last.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import "./chunk-ARZ5BDR6.mjs";
|
|
2
|
+
import "./chunk-YOFIBRET.mjs";
|
|
3
|
+
import {
|
|
4
|
+
snakeCase
|
|
5
|
+
} from "./chunk-VRFIBW4H.mjs";
|
|
6
|
+
import "./chunk-MAJSPFA6.mjs";
|
|
7
|
+
import {
|
|
8
|
+
isNil
|
|
9
|
+
} from "./chunk-OHQAR5AU.mjs";
|
|
10
|
+
import {
|
|
11
|
+
isNotNil
|
|
12
|
+
} from "./chunk-BMRTZMRE.mjs";
|
|
13
|
+
import {
|
|
14
|
+
isNull
|
|
15
|
+
} from "./chunk-AIRSKN47.mjs";
|
|
16
|
+
import {
|
|
17
|
+
isUndefined
|
|
18
|
+
} from "./chunk-VH2PV426.mjs";
|
|
2
19
|
import {
|
|
3
20
|
delay
|
|
4
21
|
} from "./chunk-O64NE2P4.mjs";
|
|
5
22
|
import "./chunk-PMHULJNL.mjs";
|
|
23
|
+
import {
|
|
24
|
+
pick
|
|
25
|
+
} from "./chunk-HPFDYUGP.mjs";
|
|
26
|
+
import {
|
|
27
|
+
pickBy
|
|
28
|
+
} from "./chunk-6CLH5YZ2.mjs";
|
|
6
29
|
import {
|
|
7
30
|
invert
|
|
8
31
|
} from "./chunk-74WWMNZS.mjs";
|
|
@@ -12,26 +35,32 @@ import {
|
|
|
12
35
|
import {
|
|
13
36
|
omitBy
|
|
14
37
|
} from "./chunk-BCTYOXT7.mjs";
|
|
38
|
+
import "./chunk-TLVQSNOE.mjs";
|
|
15
39
|
import {
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
40
|
+
range
|
|
41
|
+
} from "./chunk-DPH2KE6O.mjs";
|
|
18
42
|
import {
|
|
19
|
-
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-MAJSPFA6.mjs";
|
|
43
|
+
round
|
|
44
|
+
} from "./chunk-5PMKOZ2F.mjs";
|
|
22
45
|
import {
|
|
23
|
-
|
|
24
|
-
} from "./chunk-
|
|
46
|
+
clamp
|
|
47
|
+
} from "./chunk-MLCL773E.mjs";
|
|
25
48
|
import {
|
|
26
|
-
|
|
27
|
-
} from "./chunk-
|
|
49
|
+
inRange
|
|
50
|
+
} from "./chunk-BH6HLGBA.mjs";
|
|
28
51
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
52
|
+
meanBy
|
|
53
|
+
} from "./chunk-SDIMTYZW.mjs";
|
|
31
54
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import
|
|
55
|
+
mean
|
|
56
|
+
} from "./chunk-LT6E4Y4Z.mjs";
|
|
57
|
+
import {
|
|
58
|
+
sum
|
|
59
|
+
} from "./chunk-NOFHNJ5C.mjs";
|
|
60
|
+
import "./chunk-WGIVYA3P.mjs";
|
|
61
|
+
import {
|
|
62
|
+
zipObject
|
|
63
|
+
} from "./chunk-6GWEY5EL.mjs";
|
|
35
64
|
import {
|
|
36
65
|
zipWith
|
|
37
66
|
} from "./chunk-4KYXHZ4R.mjs";
|
|
@@ -57,8 +86,8 @@ import {
|
|
|
57
86
|
zip
|
|
58
87
|
} from "./chunk-IDCUZVJL.mjs";
|
|
59
88
|
import {
|
|
60
|
-
|
|
61
|
-
} from "./chunk-
|
|
89
|
+
takeRight
|
|
90
|
+
} from "./chunk-IQLKIDXF.mjs";
|
|
62
91
|
import {
|
|
63
92
|
takeRightWhile
|
|
64
93
|
} from "./chunk-NTLX2MPV.mjs";
|
|
@@ -74,6 +103,9 @@ import {
|
|
|
74
103
|
import {
|
|
75
104
|
unionWith
|
|
76
105
|
} from "./chunk-2ZCITDMK.mjs";
|
|
106
|
+
import {
|
|
107
|
+
uniqWith
|
|
108
|
+
} from "./chunk-237HGSZS.mjs";
|
|
77
109
|
import {
|
|
78
110
|
uniq
|
|
79
111
|
} from "./chunk-DVK2N4KC.mjs";
|
|
@@ -81,8 +113,8 @@ import {
|
|
|
81
113
|
uniqBy
|
|
82
114
|
} from "./chunk-OXAZEEGP.mjs";
|
|
83
115
|
import {
|
|
84
|
-
|
|
85
|
-
} from "./chunk-
|
|
116
|
+
minBy
|
|
117
|
+
} from "./chunk-IJD7FE2Z.mjs";
|
|
86
118
|
import {
|
|
87
119
|
orderBy
|
|
88
120
|
} from "./chunk-7B7W36UP.mjs";
|
|
@@ -95,6 +127,12 @@ import {
|
|
|
95
127
|
import {
|
|
96
128
|
sampleSize
|
|
97
129
|
} from "./chunk-EHSKB6DF.mjs";
|
|
130
|
+
import {
|
|
131
|
+
randomInt
|
|
132
|
+
} from "./chunk-GIWAOOFY.mjs";
|
|
133
|
+
import {
|
|
134
|
+
random
|
|
135
|
+
} from "./chunk-SYWMYQYJ.mjs";
|
|
98
136
|
import {
|
|
99
137
|
shuffle
|
|
100
138
|
} from "./chunk-G7UQ5PUR.mjs";
|
|
@@ -104,9 +142,6 @@ import {
|
|
|
104
142
|
import {
|
|
105
143
|
take
|
|
106
144
|
} from "./chunk-ME352XO7.mjs";
|
|
107
|
-
import {
|
|
108
|
-
takeRight
|
|
109
|
-
} from "./chunk-IQLKIDXF.mjs";
|
|
110
145
|
import {
|
|
111
146
|
head
|
|
112
147
|
} from "./chunk-HM2JT2RX.mjs";
|
|
@@ -122,12 +157,12 @@ import {
|
|
|
122
157
|
import {
|
|
123
158
|
keyBy
|
|
124
159
|
} from "./chunk-AJKZMN2V.mjs";
|
|
160
|
+
import {
|
|
161
|
+
last
|
|
162
|
+
} from "./chunk-KPBQ7OUY.mjs";
|
|
125
163
|
import {
|
|
126
164
|
maxBy
|
|
127
165
|
} from "./chunk-OOKNBU4V.mjs";
|
|
128
|
-
import {
|
|
129
|
-
minBy
|
|
130
|
-
} from "./chunk-IJD7FE2Z.mjs";
|
|
131
166
|
import {
|
|
132
167
|
drop
|
|
133
168
|
} from "./chunk-S3CORED5.mjs";
|
|
@@ -170,51 +205,25 @@ import {
|
|
|
170
205
|
import {
|
|
171
206
|
differenceWith
|
|
172
207
|
} from "./chunk-6NVQAHXP.mjs";
|
|
173
|
-
import "./chunk-
|
|
174
|
-
import
|
|
175
|
-
round
|
|
176
|
-
} from "./chunk-5PMKOZ2F.mjs";
|
|
177
|
-
import {
|
|
178
|
-
clamp
|
|
179
|
-
} from "./chunk-MLCL773E.mjs";
|
|
180
|
-
import {
|
|
181
|
-
inRange
|
|
182
|
-
} from "./chunk-BH6HLGBA.mjs";
|
|
183
|
-
import {
|
|
184
|
-
meanBy
|
|
185
|
-
} from "./chunk-SDIMTYZW.mjs";
|
|
186
|
-
import {
|
|
187
|
-
mean
|
|
188
|
-
} from "./chunk-LT6E4Y4Z.mjs";
|
|
189
|
-
import {
|
|
190
|
-
sum
|
|
191
|
-
} from "./chunk-NOFHNJ5C.mjs";
|
|
192
|
-
import {
|
|
193
|
-
randomInt
|
|
194
|
-
} from "./chunk-GIWAOOFY.mjs";
|
|
195
|
-
import {
|
|
196
|
-
random
|
|
197
|
-
} from "./chunk-SYWMYQYJ.mjs";
|
|
198
|
-
import {
|
|
199
|
-
range
|
|
200
|
-
} from "./chunk-DPH2KE6O.mjs";
|
|
208
|
+
import "./chunk-2M3YVRFS.mjs";
|
|
209
|
+
import "./chunk-T5URDZEQ.mjs";
|
|
201
210
|
import "./chunk-FZEZH22H.mjs";
|
|
202
211
|
import {
|
|
203
212
|
AbortError
|
|
204
213
|
} from "./chunk-DXB7EZUQ.mjs";
|
|
205
214
|
import "./chunk-N6EM6ETS.mjs";
|
|
206
|
-
import {
|
|
207
|
-
debounce
|
|
208
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
209
|
-
import {
|
|
210
|
-
noop
|
|
211
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
212
215
|
import {
|
|
213
216
|
once
|
|
214
217
|
} from "./chunk-CMBC4MXG.mjs";
|
|
215
218
|
import {
|
|
216
219
|
throttle
|
|
217
220
|
} from "./chunk-QOJGMVVR.mjs";
|
|
221
|
+
import {
|
|
222
|
+
debounce
|
|
223
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
224
|
+
import {
|
|
225
|
+
noop
|
|
226
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
218
227
|
import "./chunk-2MM5EJJX.mjs";
|
|
219
228
|
export {
|
|
220
229
|
AbortError,
|
|
@@ -246,6 +255,7 @@ export {
|
|
|
246
255
|
isNull,
|
|
247
256
|
isUndefined,
|
|
248
257
|
keyBy,
|
|
258
|
+
last,
|
|
249
259
|
maxBy,
|
|
250
260
|
mean,
|
|
251
261
|
meanBy,
|
|
@@ -265,6 +275,7 @@ export {
|
|
|
265
275
|
sample,
|
|
266
276
|
sampleSize,
|
|
267
277
|
shuffle,
|
|
278
|
+
snakeCase,
|
|
268
279
|
sum,
|
|
269
280
|
tail,
|
|
270
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";
|
|
@@ -23,9 +26,6 @@ import {
|
|
|
23
26
|
import {
|
|
24
27
|
random
|
|
25
28
|
} from "../chunk-SYWMYQYJ.mjs";
|
|
26
|
-
import {
|
|
27
|
-
range
|
|
28
|
-
} from "../chunk-DPH2KE6O.mjs";
|
|
29
29
|
import "../chunk-2MM5EJJX.mjs";
|
|
30
30
|
export {
|
|
31
31
|
clamp,
|
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';
|
package/dist/chunk-LOY6PATI.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-LOY6PATI.mjs.map
|
|
File without changes
|