From ea0c660da56c63e0674fe1d6cd9ab821b51a712c Mon Sep 17 00:00:00 2001 From: Eduardo Grajales Villanueva Date: Mon, 11 Jul 2022 17:34:48 -0500 Subject: [PATCH] Simplify hexToBytes calculation --- index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/index.js b/index.js index 3052c5e..0f4e283 100644 --- a/index.js +++ b/index.js @@ -24,11 +24,7 @@ function intToBytes(num) { * @return {Array} bytes */ function hexToBytes(hex) { - var bytes = []; - for(var c = 0, C = hex.length; c < C; c += 2) { - bytes.push(parseInt(hex.substr(c, 2), 16)); - } - return bytes; + return hex.match(/.{1,2}/g).map((v) => parseInt(v, 16)); } var hotp = {};