mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 12:45:50 +00:00
Browser Compatibility Updates (#107)
* BigInt -> big-integer to support older browsers * Buffer read/write BigUInt64 removed for browser compatibility.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user