Browser Compatibility Updates (#107)

* BigInt -> big-integer to support older browsers
* Buffer read/write BigUInt64 removed for browser compatibility.
This commit is contained in:
Nathan Nichols
2020-10-22 15:36:45 -05:00
parent b197897227
commit b43e79a9af
10 changed files with 1288 additions and 1215 deletions

View File

@@ -1,5 +1,6 @@
import { coreTypes } from "./types";
import { Decimal } from "decimal.js";
import * as bigInt from "big-integer";
/**
* class for encoding and decoding quality
@@ -15,7 +16,7 @@ class quality {
const decimal = new Decimal(quality);
const exponent = decimal.e - 15;
const qualityString = decimal.times(`1e${-exponent}`).abs().toString();
const bytes = coreTypes.UInt64.from(BigInt(qualityString)).toBytes();
const bytes = coreTypes.UInt64.from(bigInt(qualityString)).toBytes();
bytes[0] = exponent + 100;
return bytes;
}