UNPKG

stringzy

Version:

A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.

16 lines (15 loc) 511 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isHexColor = isHexColor; /** * Checks if the input string is a valid hex color (e.g., "#fff", "#ffffff", "fff", "ffffff"). * * @param color - The string to validate. * @returns True if the string is a valid hex color, false otherwise. */ function isHexColor(text) { if (typeof text !== 'string' || text.length === 0) { return false; } return /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(text.trim()); }