From 15fbec9a7ce698d40af028db2f698942830cb89f Mon Sep 17 00:00:00 2001 From: edo999 Date: Sat, 18 May 2024 18:03:51 +0100 Subject: [PATCH] =?UTF-8?q?Force=20the=20number=20of=20digits=20in=20hex()?= =?UTF-8?q?=20)=20=F0=9F=96=90=F0=9F=8F=BD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/utils.js b/src/lib/utils.js index 4bde8e8..3c31d45 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -2,10 +2,10 @@ const zeroPad = (s, len = 2) => { return String(s).padStart(len, '0'); }; -const hex = (n, len = 2) => { +const hex = (n, len = null) => { const str = n.toString(16); const l = Math.ceil(str.length / 2) * 2; // Even number of 0s. - return zeroPad(str, Math.max(len, l)); + return zeroPad(str, len || l); }; const formatBytes = (bytes, decimals = 2) => {