@cryptoeconomicslab/primitives
Advanced tools
Comparing version 0.0.14 to 0.0.15
import Codable from './Codable'; | ||
import JSBI from 'jsbi'; | ||
export default class BigNumber implements Codable { | ||
data: bigint; | ||
data: JSBI; | ||
static MAX_NUMBER: BigNumber; | ||
static fromString(str: string): BigNumber; | ||
static fromHexString(hex: string): BigNumber; | ||
static from(data: number | bigint | BigNumber): BigNumber; | ||
static from(data: number | JSBI | BigNumber): BigNumber; | ||
static default(): BigNumber; | ||
constructor(data: bigint); | ||
constructor(data: JSBI); | ||
get raw(): string; | ||
setData(num: bigint): void; | ||
setData(num: JSBI): void; | ||
toString(): string; | ||
@@ -13,0 +14,0 @@ toHexString(prefixRequired?: boolean): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const jsbi_1 = tslib_1.__importDefault(require("jsbi")); | ||
class BigNumber { | ||
@@ -8,3 +10,3 @@ constructor(data) { | ||
static fromString(str) { | ||
return new BigNumber(BigInt(str)); | ||
return new BigNumber(jsbi_1.default.BigInt(str)); | ||
} | ||
@@ -16,3 +18,3 @@ static fromHexString(hex) { | ||
if (match) { | ||
return new BigNumber(BigInt(hex)); | ||
return new BigNumber(jsbi_1.default.BigInt(hex)); | ||
} | ||
@@ -24,14 +26,8 @@ else { | ||
static from(data) { | ||
if (typeof data == 'number') { | ||
return new BigNumber(BigInt(data)); | ||
} | ||
else if (typeof data == 'bigint') { | ||
return new BigNumber(data); | ||
} | ||
else { | ||
if (data instanceof BigNumber) | ||
return data; | ||
} | ||
return new BigNumber(jsbi_1.default.BigInt(data.toString())); | ||
} | ||
static default() { | ||
return new BigNumber(BigInt(0)); | ||
return new BigNumber(jsbi_1.default.BigInt(0)); | ||
} | ||
@@ -56,3 +52,3 @@ get raw() { | ||
exports.default = BigNumber; | ||
BigNumber.MAX_NUMBER = new BigNumber(BigInt(2) ** BigInt(256) - BigInt(1)); | ||
BigNumber.MAX_NUMBER = new BigNumber(jsbi_1.default.subtract(jsbi_1.default.exponentiate(jsbi_1.default.BigInt(2), jsbi_1.default.BigInt(256)), jsbi_1.default.BigInt(1))); | ||
//# sourceMappingURL=BigNumber.js.map |
{ | ||
"name": "@cryptoeconomicslab/primitives", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "primitive types", | ||
@@ -32,2 +32,3 @@ "author": { | ||
"dependencies": { | ||
"jsbi": "^3.1.1", | ||
"text-encoding": "^0.7.0" | ||
@@ -38,3 +39,3 @@ }, | ||
}, | ||
"gitHead": "52c475232366fbc2fe25bb6da514c7455f6e1a68" | ||
"gitHead": "810b97e68e7b01d650331f51fc70fdf14deeef49" | ||
} |
Sorry, the diff of this file is not supported yet
37511
2
478
+ Addedjsbi@^3.1.1
+ Addedjsbi@3.2.5(transitive)