mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
8 lines
317 B
TypeScript
8 lines
317 B
TypeScript
/** Decode one ASCII hexadecimal digit, or return -1 for any other code. */
|
|
export const hexDigitValue = (code: number): number => {
|
|
if (code >= 0x30 && code <= 0x39) return code - 0x30;
|
|
if (code >= 0x41 && code <= 0x46) return code - 0x37;
|
|
if (code >= 0x61 && code <= 0x66) return code - 0x57;
|
|
return -1;
|
|
};
|