@stryke/prisma-trpc-generator
Version:
A fork of the prisma-trpc-generator code to work in ESM with Prisma v6.
21 lines (19 loc) • 945 B
JavaScript
import { ACRONYMS } from "./acronyms.mjs";
import { combine } from "./combine.mjs";
import { decamelize } from "./decamelize.mjs";
import { formatSpecialCases } from "./format-special-cases.mjs";
import { upperCaseFirst } from "./upper-case-first.mjs";
//#region ../string-format/src/title-case.ts
/**
* Convert a string to title case.
*
* @param input - The input string to convert.
* @param options - Options for formatting special cases.
* @returns The title cased string.
*/
function titleCase(input, options) {
return input?.replaceAll(":", " - ")?.replaceAll("+", " + ")?.split(/\s+-\s+/).map((segment) => decamelize(segment).split(/[\s\-_]/).map(upperCaseFirst).map((value) => options?.expandAcronyms ? ACRONYMS[value]?.description || value : value).map((value, index, array) => formatSpecialCases(value, index, array, options)).reduce(combine)).join(" - ");
}
//#endregion
export { titleCase };
//# sourceMappingURL=title-case.mjs.map