nitropage
Version:
A free and open source, extensible visual page builder based on SolidStart.
15 lines (10 loc) • 333 B
text/typescript
import { startCase } from "es-toolkit/string";
const separatorRegex = /([^a-zA-Z0-9_])/;
export function titleCase(str: string): string {
if (str === "") return str;
let result = "";
for (const part of str.split(separatorRegex)) {
result += part.length <= 1 ? part : startCase(part);
}
return result.trimStart();
}