Usage example:
import { titleCase } from "https://gist.githubusercontent.com/crabmusket/cd10f732e847afd023a00f6a45bd0d72/raw/558463e1c2a5aa910915a21396b105cefd1254d9/title_case.ts";
console.log(titleCase("deno is AWESOME"));
console.log(titleCase("words-can contain_punctuation"));
console.log(titleCase(" spacing is preserved"));
Prints:
Deno Is Awesome
Words-can Contain_punctuation
Spacing Is Preserved
Run tests:
$ deno https://gist.githubusercontent.com/crabmusket/cd10f732e847afd023a00f6a45bd0d72/raw/558463e1c2a5aa910915a21396b105cefd1254d9/title_case_test.ts
running 4 tests
OK titleCaseWorksWithAscii (0.00ms)
OK titleCaseWorksWithUnicode (0.00ms)
OK titleCasePreservesSpaces (0.00ms)
OK titleCaseTreatsPunctuationAsLetters (0.00ms)
OK titleCaseWorksWithEmoji (0.00ms)
test result: OK. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (2.00ms)