UNPKG

superflected

Version:

A port of ActiveSupport's inflector to Node.js

9 lines (7 loc) 306 B
import { humanize } from "./humanize"; import { underscore } from "./underscore"; export function titleize(word: string) { return humanize(underscore(word)).replace(/(^|[\s¿/]+)([a-z])/g, function (match, boundary, letter, idx, string) { return match.replace(letter, letter.toUpperCase()); }); }