chore: reorganize docs apps (#7228)
* reorganize docs apps * add README * fix directory * add condition for old docs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * from "./get-type-children"
|
||||
export * from "./get-project-child"
|
||||
export * from "./get-type-str"
|
||||
export * from "./str-formatting"
|
||||
export * from "./str-utils"
|
||||
|
||||
77
docs-util/packages/utils/src/str-formatting.ts
Normal file
77
docs-util/packages/utils/src/str-formatting.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
export function kebabToSnake(str: string): string {
|
||||
return str.replaceAll("-", "_")
|
||||
}
|
||||
|
||||
export function capitalize(str: string): string {
|
||||
return `${str.charAt(0).toUpperCase()}${str.substring(1).toLowerCase()}`
|
||||
}
|
||||
|
||||
export function wordsToCamel(str: string): string {
|
||||
return `${str.charAt(0).toLowerCase()}${str
|
||||
.substring(1)
|
||||
.replaceAll(/\s([a-zA-Z])/g, (captured) => captured.toUpperCase())}`
|
||||
}
|
||||
|
||||
export function camelToWords(str: string): string {
|
||||
return str
|
||||
.replaceAll(/([A-Z])/g, " $1")
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
export function camelToTitle(str: string): string {
|
||||
return str
|
||||
.replaceAll(/([A-Z])/g, " $1")
|
||||
.split(" ")
|
||||
.map((word) => capitalize(word))
|
||||
.join(" ")
|
||||
.trim()
|
||||
}
|
||||
|
||||
export function snakeToWords(str: string): string {
|
||||
return str.replaceAll("_", " ").toLowerCase()
|
||||
}
|
||||
|
||||
export function kebabToTitle(str: string): string {
|
||||
return str
|
||||
.split("-")
|
||||
.map((word) => capitalize(word))
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
export function kebabToCamel(str: string): string {
|
||||
return str
|
||||
.split("-")
|
||||
.map((word, index) => {
|
||||
if (index === 0) {
|
||||
return word
|
||||
}
|
||||
return `${word.charAt(0).toUpperCase()}${word.substring(1)}`
|
||||
})
|
||||
.join("")
|
||||
}
|
||||
|
||||
export function kebabToPascal(str: string): string {
|
||||
return str
|
||||
.split("-")
|
||||
.map((word) => capitalize(word))
|
||||
.join("")
|
||||
}
|
||||
|
||||
export function wordsToKebab(str: string): string {
|
||||
return str
|
||||
.split(" ")
|
||||
.map((word) => word.toLowerCase())
|
||||
.join("-")
|
||||
}
|
||||
|
||||
export function wordsToPascal(str: string): string {
|
||||
return str
|
||||
.split(" ")
|
||||
.map((word) => capitalize(word))
|
||||
.join("")
|
||||
}
|
||||
|
||||
export function pascalToCamel(str: string): string {
|
||||
return `${str.charAt(0).toLowerCase()}${str.substring(1)}`
|
||||
}
|
||||
Reference in New Issue
Block a user