Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1637x 1637x 2558x 1637x 5x 5x | import { Authority } from "shared-types/authority"; export function removeUnderscoresAndCapitalize(str: Authority | string): string { // Replace underscores with spaces const withoutUnderscores = str.replace(/_/g, " "); // Capitalize the first letter of every word const capitalized = withoutUnderscores .split(" ") .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); // Remove 's' from the end if it exists return capitalized.endsWith("s") ? capitalized.slice(0, -1) : capitalized; } export function convertCamelCaseToWords(input: string) { return input .replace(/([a-z])([A-Z])/g, "$1 $2") // Insert space between lowercase and uppercase letters .replace(/^./, (str) => str.toUpperCase()) // Capitalize the first letter .trim(); // Remove any leading/trailing spaces } |