aboutsummaryrefslogtreecommitdiff
path: root/src/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.ts')
-rw-r--r--src/util.ts5
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_],
+}