@technobuddha/library
Version:
A large library of useful functions
21 lines (20 loc) • 819 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHumanCase = void 0;
var constants_1 = require("../constants");
var toCapitalCase_1 = __importDefault(require("../toCapitalCase"));
var 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
*/
function toHumanCase(input) {
return toCapitalCase_1.default(input.trim().replace(/[-_.\s]+/ug, constants_1.space).replace(re, function (c) { return c.slice(0, 1) + " " + c.slice(1); }), { lowerCase: true });
}
exports.toHumanCase = toHumanCase;
exports.default = toHumanCase;