@visulima/string
Version:
Functions for manipulating strings.
29 lines (27 loc) • 736 B
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const identifyCase = /* @__PURE__ */ __name((value) => {
if (typeof value !== "string" || !value) {
return "lower";
}
if (value === value.toLowerCase()) {
if (value.includes("_")) {
return "snake";
}
if (value.includes("-")) {
return "kebab";
}
return "lower";
}
if (value === value.toUpperCase()) {
return "upper";
}
if (/^[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)*$/.test(value)) {
return "pascal";
}
if (/^[a-z0-9]+(?:[A-Z][a-z0-9]+)*$/.test(value)) {
return "camel";
}
return "mixed";
}, "identifyCase");
export { identifyCase as default };