Skip to main content

Function: isHex()

function isHex(value, byteLength?): value is Hex;

Defined in: packages/overcast-core/src/utils.ts:53

Whether value is well-formed hex: 0x followed by an even number of hex digits, and — when byteLength is given — exactly that many bytes.

A type guard, so a validated string narrows without a cast. Upper-case digits are accepted and then normalized by parseHex: hex values are canonically lower case so two encodings of the same bytes compare ===.

Parameters

ParameterType
valuestring
byteLength?number

Returns

value is Hex