diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-05-05 13:17:13 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-05-05 13:19:02 +1000 |
| commit | 6bb1d2e369512bec91ecc0c63238f4ad4c54c528 (patch) | |
| tree | 1ff7b085fb518ec69c4d1cc82879d4f588a43991 /src/util.ts | |
| parent | 975638afe73b3aec4617987800fc6871e6134469 (diff) | |
Display common names
Also add capitalizeWords() in util.ts, for more capitalization control
Diffstat (limited to 'src/util.ts')
| -rw-r--r-- | src/util.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts index a698d23..78b7870 100644 --- a/src/util.ts +++ b/src/util.ts @@ -97,3 +97,8 @@ export function randWeightedChoice(weights: number[]): number | null { } return null; } +// Returns a string with words first-letter capitalised +export function capitalizeWords(str: string){ + return str.replace(/\b\w/g, x => x.toUpperCase()); + // '\b' matches word boundary, '\w' is like [a-zA-Z0-9_], +} |
