@ethersproject/bignumber
Advanced tools
Comparing version 5.4.1 to 5.4.2
@@ -1,2 +0,2 @@ | ||
export declare const version = "bignumber/5.4.1"; | ||
export declare const version = "bignumber/5.4.2"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "bignumber/5.4.1"; | ||
export const version = "bignumber/5.4.2"; | ||
//# sourceMappingURL=_version.js.map |
@@ -92,9 +92,14 @@ "use strict"; | ||
} | ||
// Get significant digits to check truncation for underflow | ||
{ | ||
const sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, (all, sig, zeros) => (sig)); | ||
if (sigFraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// Trim trialing zeros | ||
while (fraction[fraction.length - 1] === "0") { | ||
fraction = fraction.substring(0, fraction.length - 1); | ||
} | ||
// Check the fraction doesn't exceed our decimals | ||
if (fraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// If decimals is 0, we have an empty string for fraction | ||
if (fraction === "") { | ||
fraction = "0"; | ||
} | ||
// Fully pad the string with zeros to get to wei | ||
@@ -101,0 +106,0 @@ while (fraction.length < multiplier.length - 1) { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "bignumber/5.4.1"; | ||
export declare const version = "bignumber/5.4.2"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "bignumber/5.4.1"; | ||
exports.version = "bignumber/5.4.2"; | ||
//# sourceMappingURL=_version.js.map |
@@ -95,9 +95,14 @@ "use strict"; | ||
} | ||
// Get significant digits to check truncation for underflow | ||
{ | ||
var sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, function (all, sig, zeros) { return (sig); }); | ||
if (sigFraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// Trim trialing zeros | ||
while (fraction[fraction.length - 1] === "0") { | ||
fraction = fraction.substring(0, fraction.length - 1); | ||
} | ||
// Check the fraction doesn't exceed our decimals | ||
if (fraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// If decimals is 0, we have an empty string for fraction | ||
if (fraction === "") { | ||
fraction = "0"; | ||
} | ||
// Fully pad the string with zeros to get to wei | ||
@@ -104,0 +109,0 @@ while (fraction.length < multiplier.length - 1) { |
@@ -20,3 +20,3 @@ { | ||
], | ||
"gitHead": "0d40156fcba5be155aa5def71bcdb95b9c11d889", | ||
"gitHead": "4166b2753d0d6b230a3a22b5a2b6c4e1906a7af7", | ||
"keywords": [ | ||
@@ -43,5 +43,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0xfee7ec376bfc8eb2668be2c881831293bad60c7b03f1b32c95cdc668296219fa", | ||
"tarballHash": "0x7bf3f4803f1cf34254178ed8f023a0bef9ffc4c2312ec9499a2521fdd2f403cb", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.4.1" | ||
"version": "5.4.2" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "bignumber/5.4.1"; | ||
export const version = "bignumber/5.4.2"; |
@@ -71,2 +71,3 @@ "use strict"; | ||
export function parseFixed(value: string, decimals?: BigNumberish): BigNumber { | ||
if (decimals == null) { decimals = 0; } | ||
@@ -97,10 +98,15 @@ const multiplier = getMultiplier(decimals); | ||
// Get significant digits to check truncation for underflow | ||
{ | ||
const sigFraction = fraction.replace(/^([0-9]*?)(0*)$/, (all, sig, zeros) => (sig)); | ||
if (sigFraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// Trim trialing zeros | ||
while (fraction[fraction.length - 1] === "0") { | ||
fraction = fraction.substring(0, fraction.length - 1); | ||
} | ||
// Check the fraction doesn't exceed our decimals | ||
if (fraction.length > multiplier.length - 1) { | ||
throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); | ||
} | ||
// If decimals is 0, we have an empty string for fraction | ||
if (fraction === "") { fraction = "0"; } | ||
// Fully pad the string with zeros to get to wei | ||
@@ -119,2 +125,3 @@ while (fraction.length < multiplier.length - 1) { fraction += "0"; } | ||
export class FixedFormat { | ||
@@ -121,0 +128,0 @@ readonly signed: 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
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
143766
2173