diff --git a/src/utils.ts b/src/utils.ts index e584db6..ba76713 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -68,11 +68,11 @@ export function bytesToHex(bytes: Uint8Array): string { } // We use optimized technique to convert hex string to byte array -const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 } as const; +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const; function asciiToBase16(ch: number): number | undefined { if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48 - if (ch >= asciis._A && ch <= asciis._F) return ch - (asciis._A - 10); // 'B' => 66-(65-10) - if (ch >= asciis._a && ch <= asciis._f) return ch - (asciis._a - 10); // 'b' => 98-(97-10) + if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10) return; } diff --git a/test/utils.test.js b/test/utils.test.js index d5509f8..614983f 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -3,7 +3,15 @@ const fc = require('fast-check'); const { describe, should } = require('micro-should'); const { optional, integer, gen } = require('./generator'); const { TYPE_TEST } = require('./utils'); -const { byteSwap, byteSwapIfBE, byteSwap32, isLE, bytesToHex, concatBytes, hexToBytes } = require('../utils'); +const { + byteSwap, + byteSwapIfBE, + byteSwap32, + isLE, + bytesToHex, + concatBytes, + hexToBytes, +} = require('../utils'); describe('utils', () => { const staticHexVectors = [