From 6bb1d2e369512bec91ecc0c63238f4ad4c54c528 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Thu, 5 May 2022 13:17:13 +1000 Subject: Display common names Also add capitalizeWords() in util.ts, for more capitalization control --- src/util.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/util.ts') 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_], +} -- cgit v1.2.3