ConstPure-JavaScript hex decoder, exported for benchmarking and for
environments where the native TC39 Uint8Array.fromHex intrinsic
(proposal-arraybuffer-base64) is unavailable or has been removed.
See decodeHex below for the dispatched default.
Accepts both upper- and lowercase input. Throws on odd-length input
and on any character outside [0-9a-fA-F].
Computes nibble values directly from character codes rather than
indexing a lookup table. On V8 (Node 22), this is roughly 2.5 to 3
times faster than the table-based decoder for ~1 MiB inputs and
avoids any module-scope mutable data. On XS the polyfill is
unavoidably slow regardless of approach; see test/decode.bench.js
for variants and the relative trade-offs. XS consumers should
always reach the native Uint8Array.fromHex intrinsic dispatched
below as soon as Moddable ships it.
Optionalname: string = '<unknown>'Name of the string for error diagnostics.
Decodes a hex string to a Uint8Array. Accepts both upper- and lowercase input. Throws on odd-length strings and on characters outside
[0-9a-fA-F].Dispatches to the native
Uint8Array.fromHexintrinsic when available (stage-4 TC39 proposal-arraybuffer-base64). On any native throw, re-runsjsDecodeHexto produce a diagnostic with precise offset information since native error messages are implementation-defined and do not report the failing offset.