@kubb/plugin-ts 5.3.0 → 5.3.2
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/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,15 +23,23 @@ let yuku_codegen = require("yuku-codegen");
|
|
|
23
23
|
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
24
24
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
25
25
|
// ../../internals/utils/src/casing.ts
|
|
26
|
+
const wordStart = /(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/;
|
|
27
|
+
/**
|
|
28
|
+
* Splits `text` into words on separators (whitespace, hyphens, underscores, dots, slashes, colons)
|
|
29
|
+
* and on {@link wordStart}. A segment without lowercase letters, such as `COOL` or `2D`, is one word,
|
|
30
|
+
* so snake case leaves a name that is already in it unchanged.
|
|
31
|
+
*/
|
|
32
|
+
function words(text) {
|
|
33
|
+
return text.split(/[\s\-_./\\:]+/).filter(Boolean).flatMap((segment) => segment === segment.toUpperCase() ? segment : segment.split(wordStart));
|
|
34
|
+
}
|
|
26
35
|
/**
|
|
27
36
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
28
|
-
*
|
|
29
|
-
* and capitalizes each word according to `pascal`.
|
|
37
|
+
* Capitalizes each word from {@link words} according to `pascal`.
|
|
30
38
|
*
|
|
31
39
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
32
40
|
*/
|
|
33
41
|
function convert(text, pascal) {
|
|
34
|
-
return text.
|
|
42
|
+
return words(text).flatMap((word) => word.split(/(?<=\d)(?=[a-z])|(?<=[A-Z])(?=[A-Z][a-z])/)).map((word, i) => {
|
|
35
43
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
36
44
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
37
45
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
@@ -81,7 +89,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
81
89
|
* `snakeCase('Hello-World') // 'hello_world'`
|
|
82
90
|
*/
|
|
83
91
|
function snakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
84
|
-
return `${prefix} ${text} ${suffix}
|
|
92
|
+
return words(`${prefix} ${text} ${suffix}`).map((word) => word.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()).filter(Boolean).join("_");
|
|
85
93
|
}
|
|
86
94
|
/**
|
|
87
95
|
* Converts `text` to SCREAMING_SNAKE_CASE.
|
|
@@ -1918,7 +1926,7 @@ var compatibility = {
|
|
|
1918
1926
|
"node": ">=22.22"
|
|
1919
1927
|
};
|
|
1920
1928
|
// package.json
|
|
1921
|
-
var version = "5.3.
|
|
1929
|
+
var version = "5.3.2";
|
|
1922
1930
|
// src/resolvers/resolverTs.ts
|
|
1923
1931
|
/**
|
|
1924
1932
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|