@cosmjs/math
Advanced tools
Comparing version 0.20.0 to 0.21.0
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Decimal = void 0; | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
@@ -72,2 +73,7 @@ // Too large values lead to massive memory usage. Limit to something sensible. | ||
} | ||
static compare(a, b) { | ||
if (a.fractionalDigits !== b.fractionalDigits) | ||
throw new Error("Fractional digits do not match"); | ||
return a.data.atomics.cmp(new bn_js_1.default(b.atomics)); | ||
} | ||
get atomics() { | ||
@@ -113,4 +119,19 @@ return this.data.atomics.toString(); | ||
} | ||
equals(b) { | ||
return Decimal.compare(this, b) === 0; | ||
} | ||
isLessThan(b) { | ||
return Decimal.compare(this, b) < 0; | ||
} | ||
isLessThanOrEqual(b) { | ||
return Decimal.compare(this, b) <= 0; | ||
} | ||
isGreaterThan(b) { | ||
return Decimal.compare(this, b) > 0; | ||
} | ||
isGreaterThanOrEqual(b) { | ||
return Decimal.compare(this, b) >= 0; | ||
} | ||
} | ||
exports.Decimal = Decimal; | ||
//# sourceMappingURL=decimal.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var decimal_1 = require("./decimal"); | ||
exports.Decimal = decimal_1.Decimal; | ||
Object.defineProperty(exports, "Decimal", { enumerable: true, get: function () { return decimal_1.Decimal; } }); | ||
var integers_1 = require("./integers"); | ||
exports.Int53 = integers_1.Int53; | ||
exports.Uint32 = integers_1.Uint32; | ||
exports.Uint53 = integers_1.Uint53; | ||
exports.Uint64 = integers_1.Uint64; | ||
Object.defineProperty(exports, "Int53", { enumerable: true, get: function () { return integers_1.Int53; } }); | ||
Object.defineProperty(exports, "Uint32", { enumerable: true, get: function () { return integers_1.Uint32; } }); | ||
Object.defineProperty(exports, "Uint53", { enumerable: true, get: function () { return integers_1.Uint53; } }); | ||
Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return integers_1.Uint64; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Uint64 = exports.Uint53 = exports.Int53 = exports.Uint32 = void 0; | ||
/* eslint-disable no-bitwise */ | ||
@@ -8,0 +9,0 @@ const bn_js_1 = __importDefault(require("bn.js")); |
{ | ||
"name": "@cosmjs/math", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "Math helpers for blockchain projects", | ||
@@ -28,2 +28,3 @@ "contributors": [ | ||
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"", | ||
"lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix", | ||
"format": "prettier --write --loglevel warn \"./src/**/*.ts\"", | ||
@@ -37,2 +38,3 @@ "format-text": "prettier --write --prose-wrap always --print-width 80 \"./*.md\"", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet", | ||
"move-types": "shx rm -r ./types/* && shx mv build/types/* ./types && rm -rf ./types/testdata && shx rm -f ./types/*.spec.d.ts", | ||
@@ -50,3 +52,3 @@ "format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"", | ||
}, | ||
"gitHead": "dd120779aac5743193965cdfd029979547947642" | ||
"gitHead": "0d4ab069b2277cd186a2037ac3a88a2ab914fbaa" | ||
} |
@@ -7,5 +7,4 @@ # @cosmjs/math | ||
This package is part of the cosmjs repository, licensed under the Apache | ||
License 2.0 (see | ||
[NOTICE](https://github.com/CosmWasm/cosmjs/blob/master/NOTICE) and | ||
This package is part of the cosmjs repository, licensed under the Apache License | ||
2.0 (see [NOTICE](https://github.com/CosmWasm/cosmjs/blob/master/NOTICE) and | ||
[LICENSE](https://github.com/CosmWasm/cosmjs/blob/master/LICENSE)). |
@@ -10,2 +10,3 @@ /** | ||
private static verifyFractionalDigits; | ||
static compare(a: Decimal, b: Decimal): number; | ||
get atomics(): string; | ||
@@ -27,2 +28,7 @@ get fractionalDigits(): number; | ||
plus(b: Decimal): Decimal; | ||
equals(b: Decimal): boolean; | ||
isLessThan(b: Decimal): boolean; | ||
isLessThanOrEqual(b: Decimal): boolean; | ||
isGreaterThan(b: Decimal): boolean; | ||
isGreaterThanOrEqual(b: Decimal): boolean; | ||
} |
Sorry, the diff of this file is not supported yet
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
36994
388
10