UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

30 lines (29 loc) 902 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPalindrome = void 0; exports.isCamelCase = isCamelCase; exports.isPascalCase = isPascalCase; exports.isSnakeCase = isSnakeCase; exports.isKebabCase = isKebabCase; exports.isEmojiOnly = isEmojiOnly; const convert_1 = require("./convert"); const isPalindrome = (input) => { const normalized = input.toLowerCase().replace(/[^a-z0-9]/g, ''); return normalized === (0, convert_1.reverseString)(normalized); }; exports.isPalindrome = isPalindrome; function isCamelCase(str) { return /^[a-z]+([A-Z][a-z]*)*$/.test(str); } function isPascalCase(str) { return /^[A-Z][a-zA-Z]*$/.test(str); } function isSnakeCase(str) { return /^[a-z]+(_[a-z]+)*$/.test(str); } function isKebabCase(str) { return /^[a-z]+(-[a-z]+)*$/.test(str); } function isEmojiOnly(str) { return /^[\p{Emoji}]+$/u.test(str); }