Skip to content
Permalink
Newer
Older
100644 7 lines (6 sloc) 205 Bytes
Ignoring revisions in .git-blame-ignore-revs.
July 13, 2023 09:09
1
export default function titleize(string) {
2
if (typeof string !== 'string') {
3
throw new TypeError('Expected a string');
4
}
5
6
return string.toLowerCase().replace(/(?:^|\s|-)\S/g, x => x.toUpperCase());
7
}