Skip to content

Commit

Permalink
Force the number of digits in hex() ) 🖐🏽.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarty committed May 18, 2024
1 parent ed1aadc commit 15fbec9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 15fbec9

Please sign in to comment.