UNPKG

@technobuddha/library

Version:
14 lines (13 loc) 475 B
import { space } from '../constants'; import toCapitalCase from '../toCapitalCase'; const re = /\p{Ll}\p{Lu}+/gu; /** * Convert an identifier string to human readable form * * @param input The identifer string * @returns the identifier in human readable form */ export function toHumanCase(input) { return toCapitalCase(input.trim().replace(/[-_.\s]+/ug, space).replace(re, c => `${c.slice(0, 1)} ${c.slice(1)}`), { lowerCase: true }); } export default toHumanCase;