diff options
Diffstat (limited to 'src/util.ts')
| -rw-r--r-- | src/util.ts | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts index 034879e..142e8eb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -135,6 +135,7 @@ export function randWeightedChoice(weights: number[]): number | null { export function capitalizeWords(str: string){ str = str.replace(/\b\w/g, x => x.toUpperCase()); // '\b' matches word boundary, '\w' is like [a-zA-Z0-9_] str = str.replace(/(\w)'S/, '$1\'s'); // Avoid cases like "traveler's tree" -> "Traveler'S Tree" + str = str.replace(/ And\b/, ' and'); // Avoid cases like "frogs and toads" -> "Frogs And Toads" return str; } // Used to async-await for until after a timeout |
