fix: zero-padded bit fields beyond length

This commit is contained in:
Fabio Di Stasio 2022-02-21 21:40:26 +01:00
parent 95d15de1bd
commit 265f28b4d9
1 changed files with 2 additions and 1 deletions

View File

@ -272,7 +272,8 @@ export default {
if (BIT.includes(type)) { if (BIT.includes(type)) {
if (typeof val === 'number') val = [val]; if (typeof val === 'number') val = [val];
const hex = Buffer.from(val).toString('hex'); const hex = Buffer.from(val).toString('hex');
return hexToBinary(hex); const bitString = hexToBinary(hex);
return parseInt(bitString).toString().padStart(precision, '0');
} }
if (ARRAY.includes(type)) { if (ARRAY.includes(type)) {