@exponent-labs/i80f48-util 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/i80f48.d.ts +0 -2
- package/build/i80f48.js +4 -5
- package/build/i80f48.js.map +1 -1
- package/package.json +1 -1
package/build/i80f48.d.ts
CHANGED
package/build/i80f48.js
CHANGED
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.decodeBufferLE = decodeBufferLE;
|
|
7
|
+
exports.toI80f48 = toI80f48;
|
|
8
|
+
exports.encodeI80f48ToBufferLE = encodeI80f48ToBufferLE;
|
|
9
|
+
exports.stringToI80f48Buffer = stringToI80f48Buffer;
|
|
7
10
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
11
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
9
12
|
const buffer_1 = require("buffer");
|
|
@@ -18,7 +21,6 @@ function decodeBufferLE(buffer) {
|
|
|
18
21
|
const result = new bignumber_js_1.default(integerPart.toString(10)).plus(fractionalDecimal);
|
|
19
22
|
return result.toString();
|
|
20
23
|
}
|
|
21
|
-
exports.decodeBufferLE = decodeBufferLE;
|
|
22
24
|
// Function to convert a BigNumber to i80f48
|
|
23
25
|
function toI80f48(bigNum) {
|
|
24
26
|
const BIT_SHIFT = 48;
|
|
@@ -26,7 +28,6 @@ function toI80f48(bigNum) {
|
|
|
26
28
|
const shiftedNum = bigNum.multipliedBy(new bignumber_js_1.default(2).pow(BIT_SHIFT)).integerValue();
|
|
27
29
|
return shiftedNum;
|
|
28
30
|
}
|
|
29
|
-
exports.toI80f48 = toI80f48;
|
|
30
31
|
// Function to encode an i80f48 BigNumber to a 128-bit buffer in little-endian format
|
|
31
32
|
function encodeI80f48ToBufferLE(bigNum) {
|
|
32
33
|
// Convert to i80f48 format
|
|
@@ -42,7 +43,6 @@ function encodeI80f48ToBufferLE(bigNum) {
|
|
|
42
43
|
buffer.writeBigUInt64LE(BigInt(high.toFixed()), 8);
|
|
43
44
|
return buffer;
|
|
44
45
|
}
|
|
45
|
-
exports.encodeI80f48ToBufferLE = encodeI80f48ToBufferLE;
|
|
46
46
|
// Function to convert a string to an i80f48 buffer
|
|
47
47
|
function stringToI80f48Buffer(input) {
|
|
48
48
|
// Convert the string to a BigNumber
|
|
@@ -50,5 +50,4 @@ function stringToI80f48Buffer(input) {
|
|
|
50
50
|
// Encode the BigNumber to an i80f48 buffer
|
|
51
51
|
return encodeI80f48ToBufferLE(bigNum);
|
|
52
52
|
}
|
|
53
|
-
exports.stringToI80f48Buffer = stringToI80f48Buffer;
|
|
54
53
|
//# sourceMappingURL=i80f48.js.map
|
package/build/i80f48.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i80f48.js","sourceRoot":"","sources":["../src/i80f48.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i80f48.js","sourceRoot":"","sources":["../src/i80f48.ts"],"names":[],"mappings":";;;;;AAOA,wCASC;AAED,4BAOC;AAGD,wDAkBC;AAGD,oDAMC;AAvDD,gEAAoC;AACpC,kDAAsB;AACtB,mCAA+B;AAE/B,MAAM,eAAe,GAAG,EAAE,CAAA;AAC1B,MAAM,eAAe,GAAG,IAAI,eAAE,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA,CAAC,8BAA8B;AAEjF,SAAgB,cAAc,CAAC,MAAc;IAC3C,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC1C,MAAM,EAAE,GAAG,IAAI,eAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACxB,MAAM,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,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