@cosmjs/math
Advanced tools
Comparing version 0.28.11 to 0.29.0-alpha.1
@@ -18,2 +18,5 @@ "use strict"; | ||
constructor(atomics, fractionalDigits) { | ||
if (!atomics.match(/^[0-9]+$/)) { | ||
throw new Error("Invalid string format. Only non-negative integers in decimal representation supported."); | ||
} | ||
this.data = { | ||
@@ -33,3 +36,7 @@ atomics: new bn_js_1.default(atomics), | ||
let fractional; | ||
if (input.search(/\./) === -1) { | ||
if (input === "") { | ||
whole = "0"; | ||
fractional = ""; | ||
} | ||
else if (input.search(/\./) === -1) { | ||
// integer format, no separator | ||
@@ -36,0 +43,0 @@ whole = input; |
/** Internal interface to ensure all integer types can be used equally */ | ||
interface Integer { | ||
readonly toNumber: () => number; | ||
readonly toBigInt: () => bigint; | ||
readonly toString: () => string; | ||
@@ -26,2 +27,3 @@ } | ||
toNumber(): number; | ||
toBigInt(): bigint; | ||
toString(): string; | ||
@@ -34,2 +36,3 @@ } | ||
toNumber(): number; | ||
toBigInt(): bigint; | ||
toString(): string; | ||
@@ -42,2 +45,3 @@ } | ||
toNumber(): number; | ||
toBigInt(): bigint; | ||
toString(): string; | ||
@@ -62,4 +66,5 @@ } | ||
toString(): string; | ||
toBigInt(): bigint; | ||
toNumber(): number; | ||
} | ||
export {}; |
@@ -76,2 +76,5 @@ "use strict"; | ||
} | ||
toBigInt() { | ||
return BigInt(this.toNumber()); | ||
} | ||
toString() { | ||
@@ -104,2 +107,5 @@ return this.data.toString(); | ||
} | ||
toBigInt() { | ||
return BigInt(this.toNumber()); | ||
} | ||
toString() { | ||
@@ -125,2 +131,5 @@ return this.data.toString(); | ||
} | ||
toBigInt() { | ||
return BigInt(this.toNumber()); | ||
} | ||
toString() { | ||
@@ -194,2 +203,5 @@ return this.data.toString(); | ||
} | ||
toBigInt() { | ||
return BigInt(this.toString()); | ||
} | ||
toNumber() { | ||
@@ -196,0 +208,0 @@ return this.data.toNumber(); |
{ | ||
"name": "@cosmjs/math", | ||
"version": "0.28.11", | ||
"version": "0.29.0-alpha.1", | ||
"description": "Math helpers for blockchain projects", | ||
@@ -49,3 +49,3 @@ "contributors": [ | ||
"@types/eslint-plugin-prettier": "^3", | ||
"@types/jasmine": "^3.8", | ||
"@types/jasmine": "^4", | ||
"@types/karma-firefox-launcher": "^2", | ||
@@ -65,3 +65,3 @@ "@types/karma-jasmine": "^4", | ||
"glob": "^7.1.6", | ||
"jasmine": "^3.99", | ||
"jasmine": "^4", | ||
"jasmine-spec-reporter": "^6", | ||
@@ -71,3 +71,3 @@ "karma": "^6.3.14", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma-jasmine": "^4.0.1", | ||
"karma-jasmine": "^5", | ||
"karma-jasmine-html-reporter": "^1.5.4", | ||
@@ -80,6 +80,7 @@ "nyc": "^15.1.0", | ||
"typedoc": "^0.22", | ||
"typescript": "~4.4", | ||
"typescript": "~4.6", | ||
"webpack": "^5.32.0", | ||
"webpack-cli": "^4.6.0" | ||
} | ||
}, | ||
"stableVersion": "0.28.11" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36822
11
568