Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethersproject/bignumber

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/bignumber - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0

2

lib.esm/_version.d.ts

@@ -1,2 +0,2 @@

export declare const version = "bignumber/5.1.1";
export declare const version = "bignumber/5.2.0";
//# sourceMappingURL=_version.d.ts.map

@@ -1,2 +0,2 @@

export const version = "bignumber/5.1.1";
export const version = "bignumber/5.2.0";
//# sourceMappingURL=_version.js.map
import { Bytes, Hexable } from "@ethersproject/bytes";
export declare type BigNumberish = BigNumber | Bytes | string | number;
export declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
export declare function isBigNumberish(value: any): value is BigNumberish;

@@ -4,0 +4,0 @@ export declare class BigNumber implements Hexable {

@@ -34,8 +34,8 @@ import { BytesLike } from "@ethersproject/bytes";

toFormat(format: FixedFormat | string): FixedNumber;
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber;
static fromString(value: string, format?: FixedFormat | string): FixedNumber;
static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber;
static from(value: any, format?: FixedFormat | string): FixedNumber;
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber;
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber;
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber;
static from(value: any, format?: FixedFormat | string | number): FixedNumber;
static isFixedNumber(value: any): value is FixedNumber;
}
//# sourceMappingURL=fixednumber.d.ts.map

@@ -53,3 +53,8 @@ "use strict";

const whole = value.div(multiplier).toString();
value = whole + "." + fraction;
if (multiplier.length === 1) {
value = whole;
}
else {
value = whole + "." + fraction;
}
if (negative) {

@@ -68,5 +73,2 @@ value = "-" + value;

}
if (multiplier.length - 1 === 0) {
return BigNumber.from(value);
}
// Is it negative?

@@ -92,5 +94,8 @@ const negative = (value.substring(0, 1) === "-");

}
// Prevent underflow
if (fraction.length > multiplier.length - 1) {
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
// 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");
}
}

@@ -127,2 +132,5 @@ // Fully pad the string with zeros to get to wei

}
if (typeof (value) === "number") {
value = `fixed128x${value}`;
}
let signed = true;

@@ -138,3 +146,3 @@ let width = 128;

}
else if (value != null) {
else {
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);

@@ -216,3 +224,6 @@ if (!match) {

floor() {
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
let result = FixedNumber.from(comps[0], this.format);

@@ -226,3 +237,6 @@ const hasFraction = !comps[1].match(/^(0*)$/);

ceiling() {
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
let result = FixedNumber.from(comps[0], this.format);

@@ -241,3 +255,6 @@ const hasFraction = !comps[1].match(/^(0*)$/);

// If we are already in range, we're done
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
if (decimals < 0 || decimals > 80 || (decimals % 1)) {

@@ -253,3 +270,3 @@ logger.throwArgumentError("invalid decimal count", "decimals", decimals);

isZero() {
return (this._value === "0.0");
return (this._value === "0.0" || this._value === "0");
}

@@ -256,0 +273,0 @@ isNegative() {

@@ -1,2 +0,2 @@

export declare const version = "bignumber/5.1.1";
export declare const version = "bignumber/5.2.0";
//# sourceMappingURL=_version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "bignumber/5.1.1";
exports.version = "bignumber/5.2.0";
//# sourceMappingURL=_version.js.map
import { Bytes, Hexable } from "@ethersproject/bytes";
export declare type BigNumberish = BigNumber | Bytes | string | number;
export declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
export declare function isBigNumberish(value: any): value is BigNumberish;

@@ -4,0 +4,0 @@ export declare class BigNumber implements Hexable {

@@ -34,8 +34,8 @@ import { BytesLike } from "@ethersproject/bytes";

toFormat(format: FixedFormat | string): FixedNumber;
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber;
static fromString(value: string, format?: FixedFormat | string): FixedNumber;
static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber;
static from(value: any, format?: FixedFormat | string): FixedNumber;
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber;
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber;
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber;
static from(value: any, format?: FixedFormat | string | number): FixedNumber;
static isFixedNumber(value: any): value is FixedNumber;
}
//# sourceMappingURL=fixednumber.d.ts.map

@@ -55,3 +55,8 @@ "use strict";

var whole = value.div(multiplier).toString();
value = whole + "." + fraction;
if (multiplier.length === 1) {
value = whole;
}
else {
value = whole + "." + fraction;
}
if (negative) {

@@ -71,5 +76,2 @@ value = "-" + value;

}
if (multiplier.length - 1 === 0) {
return bignumber_1.BigNumber.from(value);
}
// Is it negative?

@@ -95,5 +97,8 @@ var negative = (value.substring(0, 1) === "-");

}
// Prevent underflow
if (fraction.length > multiplier.length - 1) {
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
// 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");
}
}

@@ -131,2 +136,5 @@ // Fully pad the string with zeros to get to wei

}
if (typeof (value) === "number") {
value = "fixed128x" + value;
}
var signed = true;

@@ -142,3 +150,3 @@ var width = 128;

}
else if (value != null) {
else {
var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);

@@ -224,2 +232,5 @@ if (!match) {

var comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
var result = FixedNumber.from(comps[0], this.format);

@@ -234,2 +245,5 @@ var hasFraction = !comps[1].match(/^(0*)$/);

var comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
var result = FixedNumber.from(comps[0], this.format);

@@ -249,2 +263,5 @@ var hasFraction = !comps[1].match(/^(0*)$/);

var comps = this.toString().split(".");
if (comps.length === 1) {
comps.push("0");
}
if (decimals < 0 || decimals > 80 || (decimals % 1)) {

@@ -260,3 +277,3 @@ logger.throwArgumentError("invalid decimal count", "decimals", decimals);

FixedNumber.prototype.isZero = function () {
return (this._value === "0.0");
return (this._value === "0.0" || this._value === "0");
};

@@ -263,0 +280,0 @@ FixedNumber.prototype.isNegative = function () {

{
"author": "Richard Moore <me@ricmoo.com>",
"dependencies": {
"@ethersproject/bytes": "^5.1.0",
"@ethersproject/logger": "^5.1.0",
"@ethersproject/bytes": "^5.2.0",
"@ethersproject/logger": "^5.2.0",
"bn.js": "^4.4.0"

@@ -20,3 +20,3 @@ },

],
"gitHead": "ce8f1e4015c0f27bf178238770b1325136e3351a",
"gitHead": "dad3829c2e54b1c002c83ce948dc172530f6846d",
"keywords": [

@@ -43,5 +43,5 @@ "Ethereum",

"sideEffects": false,
"tarballHash": "0x3e0d0e0c51ff62d1611ec52119f7549d3e6f35973a4b489185a70b63ed3178e9",
"tarballHash": "0xf541fda3d586d4a9bef45fda1cffa2ef3be324945925e16d0dc04470b59dce11",
"types": "./lib/index.d.ts",
"version": "5.1.1"
"version": "5.2.0"
}

@@ -1,1 +0,1 @@

export const version = "bignumber/5.1.1";
export const version = "bignumber/5.2.0";

@@ -25,3 +25,3 @@ "use strict";

export type BigNumberish = BigNumber | Bytes | string | number;
export type BigNumberish = BigNumber | Bytes | bigint | string | number;

@@ -28,0 +28,0 @@ export function isBigNumberish(value: any): value is BigNumberish {

@@ -59,5 +59,8 @@ "use strict";

const whole = value.div(multiplier).toString();
if (multiplier.length === 1) {
value = whole;
} else {
value = whole + "." + fraction;
}
value = whole + "." + fraction;
if (negative) { value = "-" + value; }

@@ -76,6 +79,2 @@

if (multiplier.length - 1 === 0) {
return BigNumber.from(value);
}
// Is it negative?

@@ -99,5 +98,8 @@ const negative = (value.substring(0, 1) === "-");

// Prevent underflow
if (fraction.length > multiplier.length - 1) {
throwFault("fractional component exceeds decimals", "underflow", "parseFixed");
// 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");
}
}

@@ -146,2 +148,6 @@

if (typeof(value) === "number") {
value = `fixed128x${value}`
}
let signed = true;

@@ -156,3 +162,3 @@ let width = 128;

signed = false;
} else if (value != null) {
} else {
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);

@@ -249,3 +255,4 @@ if (!match) { logger.throwArgumentError("invalid fixed format", "format", value); }

floor(): FixedNumber {
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) { comps.push("0"); }

@@ -263,3 +270,4 @@ let result = FixedNumber.from(comps[0], this.format);

ceiling(): FixedNumber {
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) { comps.push("0"); }

@@ -281,3 +289,4 @@ let result = FixedNumber.from(comps[0], this.format);

// If we are already in range, we're done
let comps = this.toString().split(".");
const comps = this.toString().split(".");
if (comps.length === 1) { comps.push("0"); }

@@ -295,3 +304,3 @@ if (decimals < 0 || decimals > 80 || (decimals % 1)) {

isZero(): boolean {
return (this._value === "0.0");
return (this._value === "0.0" || this._value === "0");
}

@@ -319,3 +328,3 @@

static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber {
static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string | number): FixedNumber {
// If decimals looks more like a format, and there is no format, shift the parameters

@@ -334,3 +343,3 @@ if (format == null && decimals != null && !isBigNumberish(decimals)) {

static fromString(value: string, format?: FixedFormat | string): FixedNumber {
static fromString(value: string, format?: FixedFormat | string | number): FixedNumber {
if (format == null) { format = "fixed"; }

@@ -359,3 +368,3 @@

static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber {
static fromBytes(value: BytesLike, format?: FixedFormat | string | number): FixedNumber {
if (format == null) { format = "fixed"; }

@@ -378,3 +387,3 @@

static from(value: any, format?: FixedFormat | string) {
static from(value: any, format?: FixedFormat | string | number) {
if (typeof(value) === "string") {

@@ -381,0 +390,0 @@ return FixedNumber.fromString(value, format);

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc