import { hexToRgba } from './' ; import { ObjectColor } from './' ; export const equalColorObjects = ( first , second ) : boolean => { if ( first === second ) return true ; for ( const prop in first ) { if ( ( first as unknown as Record < string , number > ) [ prop ] !== ( second as unknown as Record < string , number > ) [ prop ] ) return false ; } return true ; } ; export const equalColorString = ( first , second ) : boolean => { return first . replace ( /\s/g , '' ) === second . replace ( /\s/g , '' ) ; } ; export const equalHex = ( first , second ) : boolean => { if ( first . toLowerCase ( ) === second . toLowerCase ( ) ) return true ; return equalColorObjects ( hexToRgba ( first ) , hexToRgba ( second ) ) ; } ; export const validHex = ( hex ) : boolean => /^#?([A-Fa-f0-9]{3,4}){1,2}$/ . test ( hex ) ;