hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
82 lines • 2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = toStartCase;
exports.toStartCaseWords = toStartCaseWords;
const toWords_1 = __importDefault(require("./toWords"));
const capitalizationOverrides = {
Ui: "UI",
Us: "US",
Uk: "UK",
Gb: "GB",
Eu: "EU",
Usa: "USA",
Gui: "GUI",
Ux: "UX",
Crm: "CRM",
Lifo: "LIFO",
Fifo: "FIFO",
Erp: "ERP",
Bi: "BI",
Aws: "AWS",
Gcp: "GCP",
Arn: "ARN",
Seo: "SEO",
Ai: "AI",
Ml: "ML",
Llm: "LLM",
Saas: "SaaS",
Api: "API",
Json: "JSON",
Sql: "SQL",
Csp: "CSP",
Cors: "CORS",
Sso: "SSO",
Saml: "SAML",
Oidc: "OIDC",
Dkim: "DKIM",
Dmarc: "DMARC",
Ci: "CI",
Cd: "CD",
Ssl: "SSL",
Tls: "TLS",
Dns: "DNS",
Http: "HTTP",
Https: "HTTPS",
Ftp: "FTP",
Sftp: "SFTP",
Smtp: "SMTP",
Ip: "IP",
Cidr: "CIDR",
Cdn: "CDN",
Cname: "CNAME",
Pdf: "PDF",
Html: "HTML",
Xml: "XML",
Css: "CSS",
Mp3: "MP3",
Mp4: "MP4",
};
/**
* @param s A string in camel, pascal, snake, kebab and spaced case format.
* @returns A string in start case.
* @example toStartCase("convertMy_string") === "Convert My String"
*/
function toStartCase(s) {
return toStartCaseWords(s).join(" ");
}
/**
* @param s A string in camel, pascal, snake, kebab and spaced case format.
* @returns A list of strings in title case.
* @example toStartCase("convertMy_string") === ["Convert", "My", "String"]
*/
function toStartCaseWords(s) {
return (0, toWords_1.default)(s).map((word) => {
var _a;
const startCase = word.charAt(0).toUpperCase() + word.slice(1);
return (_a = capitalizationOverrides[startCase]) !== null && _a !== void 0 ? _a : startCase;
});
}
//# sourceMappingURL=toStartCase.js.map