chore: build

This commit is contained in:
Ewout Stortenbeker 2022-09-12 13:30:16 +02:00
parent 95bd5ccae4
commit 39eefbcddc
2 changed files with 13 additions and 11 deletions

22
dist/browser.js vendored
View file

@ -4845,27 +4845,29 @@ function bigintToBytes(number) {
}
const bytes = [];
const negative = number < big.zero;
while (number !== (negative ? -big.one : big.zero)) {
const byte = Number(number & big.ff);
do {
const byte = Number(number & big.ff); // NOTE: bits are inverted on negative numbers
bytes.push(byte);
number = number >> big.eight;
} while (number !== (negative ? -big.one : big.zero));
bytes.reverse(); // little-endian
if (negative ? bytes[0] < 128 : bytes[0] >= 128) {
bytes.unshift(negative ? 255 : 0); // extra sign byte needed
}
return bytes.reverse();
return bytes;
}
exports.bigintToBytes = bigintToBytes;
function bytesToBigint(bytes) {
const negative = bytes[0] >= 128;
let number = big.zero;
if (negative) {
bytes[0] -= 128;
}
for (const b of bytes) {
for (let b of bytes) {
if (negative) {
b = ~b & 0xff;
} // Invert the bits
number = (number << big.eight) + BigInt(b);
}
if (negative) {
// Invert the bits
const bits = (BigInt(bytes.length) * big.eight) - big.one;
number = -(big.two ** bits) + number;
number = -(number + big.one);
}
return number;
}

2
dist/browser.min.js vendored

File diff suppressed because one or more lines are too long