@web3r/flowerkit
Version:
Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).
17 lines (16 loc) • 717 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:true});
/**
* Checks if a string is in kebab-case.
* Rules:
* Lowercase letters separated by single hyphens
* No leading or trailing hyphen
*
* @param {string} str Source string
* @returns {boolean} True if string is kebab-case
* @throws {TypeError} If str is not a string
* @example
* isStrInKebabCase("good-kebab"); // true
*/const isStrInKebabCase=str=>{if(typeof str!=="string")throw new TypeError("isStrInKebabCase: str must be a string");
// eslint-disable-next-line security/detect-unsafe-regex
const pattern=/^[a-z]+(?:-[a-z]+)*$/;return!!str.length&&pattern.test(str)};exports.isStrInKebabCase=isStrInKebabCase;
//# sourceMappingURL=index.cjs.map