v0.21.0 - isHexColor validation function
Added
-
New Function:
isHexColor()- Validates hexadecimal color codes with comprehensive format support- Supports 3-digit (
#fff), 6-digit (#ffffff), 4-digit with alpha (#fff8), and 8-digit with alpha (#ffffff80) formats - Case-insensitive validation for all formats
- Pre-compiled regex for optimal performance
- Bundle size: 118 bytes raw, 103 bytes gzipped
- 100% test coverage with 32 test cases
- Use cases: design systems, theme validation, color picker validation, form validation
- Supports 3-digit (
-
Branded Type Integration for HexColor - Full type-safe color handling
- New
HexColorbranded type for compile-time safety - Type guard:
isValidHexColor()for type narrowing - Builder function:
toHexColor()returnsHexColor | nullwith validation - Assertion function:
assertHexColor()throwsBrandedTypeErroron invalid input - Unsafe cast:
unsafeHexColor()for trusted input (no validation) - Integrates seamlessly with existing branded type system
- New
Improved
- Benchmark Infrastructure - Enhanced function extraction for more accurate metrics
- Added exclusion list for 26 branded type system helpers
- Separates core utilities (49 functions) from type system infrastructure
- Prevents metric inflation in bundle size and performance benchmarks
- More accurate representation of library capabilities
- Better comparison with other libraries (lodash, es-toolkit)
Documentation
- Updated total function count from 48 to 49 core utilities
- Added
isHexColorto documentation site with interactive playground examples - Updated bundle size references to accurately reflect package size (< 12KB)
- Regenerated benchmark data with new function
Full Changelog: v0.20.0...v0.21.0