@agrozyme/numeric 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.d.ts +3 -0
- package/lib/config.js +33 -0
- package/lib/config.js.map +1 -0
- package/lib/config.mjs +28 -0
- package/lib/config.mjs.map +1 -0
- package/lib/constants.d.ts +9 -0
- package/lib/constants.js +15 -0
- package/lib/constants.js.map +1 -0
- package/lib/constants.mjs +11 -0
- package/lib/constants.mjs.map +1 -0
- package/lib/convert.d.ts +11 -0
- package/lib/convert.js +23 -0
- package/lib/convert.js.map +1 -0
- package/lib/convert.mjs +12 -0
- package/lib/convert.mjs.map +1 -0
- package/lib/format.d.ts +18 -0
- package/lib/format.js +13 -0
- package/lib/format.js.map +1 -0
- package/lib/format.mjs +8 -0
- package/lib/format.mjs.map +1 -0
- package/lib/helper.d.ts +2 -0
- package/lib/helper.js +9 -0
- package/lib/helper.js.map +1 -0
- package/lib/helper.mjs +5 -0
- package/lib/helper.mjs.map +1 -0
- package/lib/index.d.ts +8 -158
- package/lib/index.js +27 -230
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +6 -217
- package/lib/index.mjs.map +1 -1
- package/lib/numeric.d.ts +126 -0
- package/lib/numeric.js +397 -0
- package/lib/numeric.js.map +1 -0
- package/lib/numeric.mjs +392 -0
- package/lib/numeric.mjs.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +32 -0
- package/src/constants.ts +11 -0
- package/src/convert.ts +12 -0
- package/src/format.ts +25 -0
- package/src/helper.ts +6 -0
- package/src/index.ts +8 -378
- package/src/numeric.ts +517 -0
package/lib/config.d.ts
ADDED
package/lib/config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupNumericConfig = exports.getNumericConfig = void 0;
|
|
4
|
+
const numeric_1 = require("./numeric.js");
|
|
5
|
+
const getNumericConfig = () => {
|
|
6
|
+
const { precision, rounding, minE, maxE, toExpNeg, toExpPos, crypto, modulo } = numeric_1.Numeric;
|
|
7
|
+
const data = {
|
|
8
|
+
precision,
|
|
9
|
+
rounding,
|
|
10
|
+
minE,
|
|
11
|
+
maxE,
|
|
12
|
+
toExpNeg,
|
|
13
|
+
toExpPos,
|
|
14
|
+
crypto,
|
|
15
|
+
modulo,
|
|
16
|
+
defaults: false,
|
|
17
|
+
};
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
exports.getNumericConfig = getNumericConfig;
|
|
21
|
+
const setupNumericConfig = () => {
|
|
22
|
+
const config = {
|
|
23
|
+
precision: 256,
|
|
24
|
+
//rounding: Numeric.ROUND_FLOOR,
|
|
25
|
+
toExpNeg: numeric_1.Numeric.minE,
|
|
26
|
+
toExpPos: numeric_1.Numeric.maxE,
|
|
27
|
+
crypto: false,
|
|
28
|
+
};
|
|
29
|
+
numeric_1.Numeric.set({ defaults: true });
|
|
30
|
+
numeric_1.Numeric.set(config);
|
|
31
|
+
};
|
|
32
|
+
exports.setupNumericConfig = setupNumericConfig;
|
|
33
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AACA,0CAAoC;AAE7B,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,iBAAO,CAAC;IACxF,MAAM,IAAI,GAA6B;QACrC,SAAS;QACT,QAAQ;QACR,IAAI;QACJ,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAfW,QAAA,gBAAgB,oBAe3B;AAEK,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,MAAM,GAAmB;QAC7B,SAAS,EAAE,GAAG;QACd,gCAAgC;QAChC,QAAQ,EAAE,iBAAO,CAAC,IAAI;QACtB,QAAQ,EAAE,iBAAO,CAAC,IAAI;QACtB,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,iBAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,iBAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B"}
|
package/lib/config.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Numeric } from "./numeric.mjs";
|
|
2
|
+
export const getNumericConfig = () => {
|
|
3
|
+
const { precision, rounding, minE, maxE, toExpNeg, toExpPos, crypto, modulo } = Numeric;
|
|
4
|
+
const data = {
|
|
5
|
+
precision,
|
|
6
|
+
rounding,
|
|
7
|
+
minE,
|
|
8
|
+
maxE,
|
|
9
|
+
toExpNeg,
|
|
10
|
+
toExpPos,
|
|
11
|
+
crypto,
|
|
12
|
+
modulo,
|
|
13
|
+
defaults: false,
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
export const setupNumericConfig = () => {
|
|
18
|
+
const config = {
|
|
19
|
+
precision: 256,
|
|
20
|
+
//rounding: Numeric.ROUND_FLOOR,
|
|
21
|
+
toExpNeg: Numeric.minE,
|
|
22
|
+
toExpPos: Numeric.maxE,
|
|
23
|
+
crypto: false,
|
|
24
|
+
};
|
|
25
|
+
Numeric.set({ defaults: true });
|
|
26
|
+
Numeric.set(config);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"OACO,EAAE,OAAO,EAAE;AAElB,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACxF,MAAM,IAAI,GAA6B;QACrC,SAAS;QACT,QAAQ;QACR,IAAI;QACJ,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,MAAM,GAAmB;QAC7B,SAAS,EAAE,GAAG;QACd,gCAAgC;QAChC,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Numeric } from './numeric';
|
|
2
|
+
export declare const NegativeOne: Numeric;
|
|
3
|
+
export declare const Zero: Numeric;
|
|
4
|
+
export declare const One: Numeric;
|
|
5
|
+
export declare const Two: Numeric;
|
|
6
|
+
export declare const WeiPerEther: Numeric;
|
|
7
|
+
export declare const MaxUint256: Numeric;
|
|
8
|
+
export declare const MaxInt256: Numeric;
|
|
9
|
+
export declare const MinInt256: Numeric;
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinInt256 = exports.MaxInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const constants = tslib_1.__importStar(require("@ethersproject/constants"));
|
|
6
|
+
const numeric_1 = require("./numeric.js");
|
|
7
|
+
exports.NegativeOne = new numeric_1.Numeric(-1);
|
|
8
|
+
exports.Zero = new numeric_1.Numeric(0);
|
|
9
|
+
exports.One = new numeric_1.Numeric(1);
|
|
10
|
+
exports.Two = new numeric_1.Numeric(2);
|
|
11
|
+
exports.WeiPerEther = new numeric_1.Numeric(constants.WeiPerEther);
|
|
12
|
+
exports.MaxUint256 = new numeric_1.Numeric(constants.MaxUint256);
|
|
13
|
+
exports.MaxInt256 = new numeric_1.Numeric(constants.MaxInt256);
|
|
14
|
+
exports.MinInt256 = new numeric_1.Numeric(constants.MinInt256);
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;AAAA,4EAAsD;AACtD,0CAAoC;AAEvB,QAAA,WAAW,GAAG,IAAI,iBAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,QAAA,IAAI,GAAG,IAAI,iBAAO,CAAC,CAAC,CAAC,CAAC;AACtB,QAAA,GAAG,GAAG,IAAI,iBAAO,CAAC,CAAC,CAAC,CAAC;AACrB,QAAA,GAAG,GAAG,IAAI,iBAAO,CAAC,CAAC,CAAC,CAAC;AACrB,QAAA,WAAW,GAAG,IAAI,iBAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AACjD,QAAA,UAAU,GAAG,IAAI,iBAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC/C,QAAA,SAAS,GAAG,IAAI,iBAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAC7C,QAAA,SAAS,GAAG,IAAI,iBAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as constants from '@ethersproject/constants';
|
|
2
|
+
import { Numeric } from "./numeric.mjs";
|
|
3
|
+
export const NegativeOne = new Numeric(-1);
|
|
4
|
+
export const Zero = new Numeric(0);
|
|
5
|
+
export const One = new Numeric(1);
|
|
6
|
+
export const Two = new Numeric(2);
|
|
7
|
+
export const WeiPerEther = new Numeric(constants.WeiPerEther);
|
|
8
|
+
export const MaxUint256 = new Numeric(constants.MaxUint256);
|
|
9
|
+
export const MaxInt256 = new Numeric(constants.MaxInt256);
|
|
10
|
+
export const MinInt256 = new Numeric(constants.MinInt256);
|
|
11
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"OAAO,KAAK,SAAS,MAAM,0BAA0B;OAC9C,EAAE,OAAO,EAAE;AAElB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC"}
|
package/lib/convert.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import bigInt from 'big-integer';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
import { Numeric, NumericValue } from './numeric';
|
|
5
|
+
export declare const toNumeric: (value: NumericValue) => Numeric;
|
|
6
|
+
export declare const toNumerics: (values: NumericValue[]) => Numeric[];
|
|
7
|
+
export declare const toIntegerString: (value: NumericValue) => string;
|
|
8
|
+
export declare const toBigInt: (value: NumericValue) => bigint;
|
|
9
|
+
export declare const toBN: (value: NumericValue) => BN;
|
|
10
|
+
export declare const toBigInteger: (value: NumericValue) => bigInt.BigInteger;
|
|
11
|
+
export declare const toBigNumber: (value: NumericValue) => BigNumber;
|
package/lib/convert.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBigNumber = exports.toBigInteger = exports.toBN = exports.toBigInt = exports.toIntegerString = exports.toNumerics = exports.toNumeric = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
6
|
+
const big_integer_1 = tslib_1.__importDefault(require("big-integer"));
|
|
7
|
+
const bn_js_1 = tslib_1.__importDefault(require("bn.js"));
|
|
8
|
+
const numeric_1 = require("./numeric.js");
|
|
9
|
+
const toNumeric = (value) => new numeric_1.Numeric(value);
|
|
10
|
+
exports.toNumeric = toNumeric;
|
|
11
|
+
const toNumerics = (values) => values.map(exports.toNumeric);
|
|
12
|
+
exports.toNumerics = toNumerics;
|
|
13
|
+
const toIntegerString = (value) => (0, exports.toNumeric)(value).toFixed(0);
|
|
14
|
+
exports.toIntegerString = toIntegerString;
|
|
15
|
+
const toBigInt = (value) => BigInt((0, exports.toIntegerString)(value));
|
|
16
|
+
exports.toBigInt = toBigInt;
|
|
17
|
+
const toBN = (value) => new bn_js_1.default((0, exports.toIntegerString)(value));
|
|
18
|
+
exports.toBN = toBN;
|
|
19
|
+
const toBigInteger = (value) => (0, big_integer_1.default)((0, exports.toIntegerString)(value));
|
|
20
|
+
exports.toBigInteger = toBigInteger;
|
|
21
|
+
const toBigNumber = (value) => bignumber_1.BigNumber.from((0, exports.toIntegerString)(value));
|
|
22
|
+
exports.toBigNumber = toBigNumber;
|
|
23
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":";;;;AAAA,wDAAqD;AACrD,sEAAiC;AACjC,0DAAuB;AACvB,0CAAkD;AAE3C,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,KAAK,CAAC,CAAC;AAAxD,QAAA,SAAS,aAA+C;AAC9D,MAAM,UAAU,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAS,CAAC,CAAC;AAA/D,QAAA,UAAU,cAAqD;AACrE,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAAvE,QAAA,eAAe,mBAAwD;AAC7E,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAAnE,QAAA,QAAQ,YAA2D;AACzE,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,eAAE,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAA/D,QAAA,IAAI,QAA2D;AACrE,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAA,qBAAM,EAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAAvE,QAAA,YAAY,gBAA2D;AAC7E,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,qBAAS,CAAC,IAAI,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAA9E,QAAA,WAAW,eAAmE"}
|
package/lib/convert.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import bigInt from 'big-integer';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
import { Numeric } from "./numeric.mjs";
|
|
5
|
+
export const toNumeric = (value) => new Numeric(value);
|
|
6
|
+
export const toNumerics = (values) => values.map(toNumeric);
|
|
7
|
+
export const toIntegerString = (value) => toNumeric(value).toFixed(0);
|
|
8
|
+
export const toBigInt = (value) => BigInt(toIntegerString(value));
|
|
9
|
+
export const toBN = (value) => new BN(toIntegerString(value));
|
|
10
|
+
export const toBigInteger = (value) => bigInt(toIntegerString(value));
|
|
11
|
+
export const toBigNumber = (value) => BigNumber.from(toIntegerString(value));
|
|
12
|
+
//# sourceMappingURL=convert.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.mjs","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B;OAC7C,MAAM,MAAM,aAAa;OACzB,EAAE,MAAM,OAAO;OACf,EAAE,OAAO,EAAgB;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
package/lib/format.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NumericValue } from './numeric';
|
|
2
|
+
export interface IFormatNumberOptions {
|
|
3
|
+
negativeType?: 'right' | 'left' | 'brackets' | 'none';
|
|
4
|
+
negativeLeftSymbol?: string;
|
|
5
|
+
negativeRightSymbol?: string;
|
|
6
|
+
negativeLeftOut?: boolean;
|
|
7
|
+
negativeRightOut?: boolean;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
suffix?: string;
|
|
10
|
+
integerSeparator?: string;
|
|
11
|
+
decimalsSeparator?: string;
|
|
12
|
+
decimal?: string;
|
|
13
|
+
padLeft?: number;
|
|
14
|
+
padRight?: number;
|
|
15
|
+
round?: number;
|
|
16
|
+
truncate?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const formatValue: (value: NumericValue, options?: IFormatNumberOptions) => string;
|
package/lib/format.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatValue = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const format_number_1 = tslib_1.__importDefault(require("format-number"));
|
|
6
|
+
const numeric_1 = require("./numeric.js");
|
|
7
|
+
const formatValue = (value, options) => {
|
|
8
|
+
const format = (0, format_number_1.default)(options);
|
|
9
|
+
const text = new numeric_1.Numeric(value).toFixed();
|
|
10
|
+
return format(text);
|
|
11
|
+
};
|
|
12
|
+
exports.formatValue = formatValue;
|
|
13
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":";;;;AAAA,0EAAsC;AACtC,0CAAkD;AAmB3C,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,OAA8B,EAAE,EAAE;IACjF,MAAM,MAAM,GAAG,IAAA,uBAAS,EAAC,OAAO,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1C,OAAO,MAAM,CAAM,IAAI,CAAC,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,WAAW,eAItB"}
|
package/lib/format.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import formatter from 'format-number';
|
|
2
|
+
import { Numeric } from "./numeric.mjs";
|
|
3
|
+
export const formatValue = (value, options) => {
|
|
4
|
+
const format = formatter(options);
|
|
5
|
+
const text = new Numeric(value).toFixed();
|
|
6
|
+
return format(text);
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=format.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.mjs","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"OAAO,SAAS,MAAM,eAAe;OAC9B,EAAE,OAAO,EAAgB;AAmBhC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,OAA8B,EAAE,EAAE;IACjF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1C,OAAO,MAAM,CAAM,IAAI,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
package/lib/helper.d.ts
ADDED
package/lib/helper.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createArrayCompareFunction = void 0;
|
|
4
|
+
const numeric_1 = require("./numeric.js");
|
|
5
|
+
const createArrayCompareFunction = (ascending = true) => ascending
|
|
6
|
+
? (left, right) => numeric_1.Numeric.sub(left, right).toNumber()
|
|
7
|
+
: (left, right) => numeric_1.Numeric.sub(right, left).toNumber();
|
|
8
|
+
exports.createArrayCompareFunction = createArrayCompareFunction;
|
|
9
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":";;;AAAA,0CAAkD;AAE3C,MAAM,0BAA0B,GAAG,CAAC,YAAqB,IAAI,EAAE,EAAE,CACtE,SAAS;IACP,CAAC,CAAC,CAAC,IAAkB,EAAE,KAAmB,EAAE,EAAE,CAAC,iBAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;IAClF,CAAC,CAAC,CAAC,IAAkB,EAAE,KAAmB,EAAE,EAAE,CAAC,iBAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AAH1E,QAAA,0BAA0B,8BAGgD"}
|
package/lib/helper.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.mjs","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"OAAO,EAAE,OAAO,EAAgB;AAEhC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,YAAqB,IAAI,EAAE,EAAE,CACtE,SAAS;IACP,CAAC,CAAC,CAAC,IAAkB,EAAE,KAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;IAClF,CAAC,CAAC,CAAC,IAAkB,EAAE,KAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,158 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
negativeLeftSymbol?: string;
|
|
10
|
-
negativeRightSymbol?: string;
|
|
11
|
-
negativeLeftOut?: boolean;
|
|
12
|
-
negativeRightOut?: boolean;
|
|
13
|
-
prefix?: string;
|
|
14
|
-
suffix?: string;
|
|
15
|
-
integerSeparator?: string;
|
|
16
|
-
decimalsSeparator?: string;
|
|
17
|
-
decimal?: string;
|
|
18
|
-
padLeft?: number;
|
|
19
|
-
padRight?: number;
|
|
20
|
-
round?: number;
|
|
21
|
-
truncate?: number;
|
|
22
|
-
}
|
|
23
|
-
export declare class Numeric extends Decimal {
|
|
24
|
-
constructor(value: NumericValue);
|
|
25
|
-
get [Symbol.toStringTag](): string;
|
|
26
|
-
static abs: (value: NumericValue) => Numeric;
|
|
27
|
-
static acos: (value: NumericValue) => Numeric;
|
|
28
|
-
static acosh: (value: NumericValue) => Numeric;
|
|
29
|
-
static add: (x: NumericValue, y: NumericValue) => Numeric;
|
|
30
|
-
static asin: (value: NumericValue) => Numeric;
|
|
31
|
-
static asinh: (value: NumericValue) => Numeric;
|
|
32
|
-
static atan: (value: NumericValue) => Numeric;
|
|
33
|
-
static atan2: (x: NumericValue, y: NumericValue) => Numeric;
|
|
34
|
-
static atanh: (value: NumericValue) => Numeric;
|
|
35
|
-
static cbrt: (value: NumericValue) => Numeric;
|
|
36
|
-
static ceil: (value: NumericValue) => Numeric;
|
|
37
|
-
static cos: (value: NumericValue) => Numeric;
|
|
38
|
-
static cosh: (value: NumericValue) => Numeric;
|
|
39
|
-
static div: (x: NumericValue, y: NumericValue) => Numeric;
|
|
40
|
-
static exp: (value: NumericValue) => Numeric;
|
|
41
|
-
static floor: (value: NumericValue) => Numeric;
|
|
42
|
-
static hypot: (...values: NumericValue[]) => Numeric;
|
|
43
|
-
static ln: (value: NumericValue) => Numeric;
|
|
44
|
-
static log: (value: NumericValue, base?: NumericValue) => Numeric;
|
|
45
|
-
static log10: (value: NumericValue) => Numeric;
|
|
46
|
-
static log2: (value: NumericValue) => Numeric;
|
|
47
|
-
static max: (...values: NumericValue[]) => Numeric;
|
|
48
|
-
static min: (...values: NumericValue[]) => Numeric;
|
|
49
|
-
static mod: (x: NumericValue, y: NumericValue) => Numeric;
|
|
50
|
-
static mul: (x: NumericValue, y: NumericValue) => Numeric;
|
|
51
|
-
static pow: (base: NumericValue, exponent: NumericValue) => Numeric;
|
|
52
|
-
static random: (significantDigits?: number) => Numeric;
|
|
53
|
-
static round: (value: NumericValue) => Numeric;
|
|
54
|
-
static set: (object: Decimal.Config) => typeof Decimal;
|
|
55
|
-
static sign: (value: NumericValue) => number;
|
|
56
|
-
static sin: (value: NumericValue) => Numeric;
|
|
57
|
-
static sinh: (value: NumericValue) => Numeric;
|
|
58
|
-
static sqrt: (value: NumericValue) => Numeric;
|
|
59
|
-
static sub: (x: NumericValue, y: NumericValue) => Numeric;
|
|
60
|
-
static tan: (value: NumericValue) => Numeric;
|
|
61
|
-
static tanh: (value: NumericValue) => Numeric;
|
|
62
|
-
static trunc: (value: NumericValue) => Numeric;
|
|
63
|
-
abs: () => Numeric;
|
|
64
|
-
absoluteValue: () => Numeric;
|
|
65
|
-
acos: () => Numeric;
|
|
66
|
-
acosh: () => Numeric;
|
|
67
|
-
add: (value: NumericValue) => Numeric;
|
|
68
|
-
asin: () => Numeric;
|
|
69
|
-
asinh: () => Numeric;
|
|
70
|
-
atan: () => Numeric;
|
|
71
|
-
atanh: () => Numeric;
|
|
72
|
-
cbrt: () => Numeric;
|
|
73
|
-
ceil: () => Numeric;
|
|
74
|
-
cmp: (value: NumericValue) => number;
|
|
75
|
-
comparedTo: (value: NumericValue) => number;
|
|
76
|
-
cos: () => Numeric;
|
|
77
|
-
cosh: () => Numeric;
|
|
78
|
-
cosine: () => Numeric;
|
|
79
|
-
cubeRoot: () => Numeric;
|
|
80
|
-
div: (value: NumericValue) => Numeric;
|
|
81
|
-
divToInt: (value: NumericValue) => Numeric;
|
|
82
|
-
dividedBy: (value: NumericValue) => Numeric;
|
|
83
|
-
dividedToIntegerBy: (value: NumericValue) => Numeric;
|
|
84
|
-
eq: (value: NumericValue) => boolean;
|
|
85
|
-
equals: (value: NumericValue) => boolean;
|
|
86
|
-
exp: () => Numeric;
|
|
87
|
-
floor: () => Numeric;
|
|
88
|
-
greaterThan: (value: NumericValue) => boolean;
|
|
89
|
-
greaterThanOrEqualTo: (value: NumericValue) => boolean;
|
|
90
|
-
gt: (value: NumericValue) => boolean;
|
|
91
|
-
gte: (value: NumericValue) => boolean;
|
|
92
|
-
hyperbolicCosine: () => Numeric;
|
|
93
|
-
hyperbolicSine: () => Numeric;
|
|
94
|
-
hyperbolicTangent: () => Numeric;
|
|
95
|
-
inverseCosine: () => Numeric;
|
|
96
|
-
inverseHyperbolicCosine: () => Numeric;
|
|
97
|
-
inverseHyperbolicSine: () => Numeric;
|
|
98
|
-
inverseHyperbolicTangent: () => Numeric;
|
|
99
|
-
inverseSine: () => Numeric;
|
|
100
|
-
inverseTangent: () => Numeric;
|
|
101
|
-
lessThan: (value: NumericValue) => boolean;
|
|
102
|
-
lessThanOrEqualTo: (value: NumericValue) => boolean;
|
|
103
|
-
ln: () => Numeric;
|
|
104
|
-
log: (value?: NumericValue) => Numeric;
|
|
105
|
-
logarithm: (value?: NumericValue) => Numeric;
|
|
106
|
-
lt: (value: NumericValue) => boolean;
|
|
107
|
-
lte: (value: NumericValue) => boolean;
|
|
108
|
-
minus: (value: NumericValue) => Numeric;
|
|
109
|
-
mod: (value: NumericValue) => Numeric;
|
|
110
|
-
modulo: (value: NumericValue) => Numeric;
|
|
111
|
-
mul: (value: NumericValue) => Numeric;
|
|
112
|
-
naturalExponential: () => Numeric;
|
|
113
|
-
naturalLogarithm: () => Numeric;
|
|
114
|
-
neg: () => Numeric;
|
|
115
|
-
negated: () => Numeric;
|
|
116
|
-
plus: (value: NumericValue) => Numeric;
|
|
117
|
-
pow: (value: NumericValue) => Numeric;
|
|
118
|
-
round: () => Numeric;
|
|
119
|
-
sin: () => Numeric;
|
|
120
|
-
sine: () => Numeric;
|
|
121
|
-
sinh: () => Numeric;
|
|
122
|
-
sqrt: () => Numeric;
|
|
123
|
-
squareRoot: () => Numeric;
|
|
124
|
-
sub: (value: NumericValue) => Numeric;
|
|
125
|
-
tan: () => Numeric;
|
|
126
|
-
tangent: () => Numeric;
|
|
127
|
-
tanh: () => Numeric;
|
|
128
|
-
times: (value: NumericValue) => Numeric;
|
|
129
|
-
toDP: (decimalPlaces?: number, rounding?: Decimal.Rounding) => Numeric;
|
|
130
|
-
toDecimalPlaces: (decimalPlaces?: number, rounding?: Decimal.Rounding) => Numeric;
|
|
131
|
-
toFraction: (maxDenominator?: NumericValue) => Numeric[];
|
|
132
|
-
toNearest: (value: NumericValue, rounding?: Decimal.Rounding) => Numeric;
|
|
133
|
-
toPower: (value: NumericValue) => Numeric;
|
|
134
|
-
toSD: (decimalPlaces?: number, rounding?: Decimal.Rounding) => Numeric;
|
|
135
|
-
toSignificantDigits: (decimalPlaces?: number, rounding?: Decimal.Rounding) => Numeric;
|
|
136
|
-
trunc: () => Numeric;
|
|
137
|
-
truncated: () => Numeric;
|
|
138
|
-
inspect: (depth: number, options: InspectOptionsStylized) => string;
|
|
139
|
-
}
|
|
140
|
-
export declare const toNumeric: (value: NumericValue) => Numeric;
|
|
141
|
-
export declare const toNumerics: (values: NumericValue[]) => Numeric[];
|
|
142
|
-
export declare const toIntegerString: (value: NumericValue) => string;
|
|
143
|
-
export declare const toBigInt: (value: NumericValue) => bigint;
|
|
144
|
-
export declare const toBN: (value: NumericValue) => BN;
|
|
145
|
-
export declare const toBigInteger: (value: NumericValue) => bigInt.BigInteger;
|
|
146
|
-
export declare const toBigNumber: (value: NumericValue) => BigNumber;
|
|
147
|
-
export declare const createArrayCompareFunction: (ascending?: boolean) => (left: NumericValue, right: NumericValue) => number;
|
|
148
|
-
export declare const formatValue: (value: NumericValue, options?: IFormatNumberOptions) => string;
|
|
149
|
-
export declare const getNumericConfig: () => Required<Decimal.Config>;
|
|
150
|
-
export declare const setupNumericConfig: () => void;
|
|
151
|
-
export declare const NegativeOne: Numeric;
|
|
152
|
-
export declare const Zero: Numeric;
|
|
153
|
-
export declare const One: Numeric;
|
|
154
|
-
export declare const Two: Numeric;
|
|
155
|
-
export declare const WeiPerEther: Numeric;
|
|
156
|
-
export declare const MaxUint256: Numeric;
|
|
157
|
-
export declare const MaxInt256: Numeric;
|
|
158
|
-
export declare const MinInt256: Numeric;
|
|
1
|
+
export { Numeric } from './numeric';
|
|
2
|
+
export type { NumericValue } from './numeric';
|
|
3
|
+
export { getNumericConfig, setupNumericConfig } from './config';
|
|
4
|
+
export { MaxInt256, MaxUint256, MinInt256, NegativeOne, One, Two, WeiPerEther, Zero } from './constants';
|
|
5
|
+
export { toBigInt, toBigInteger, toBigNumber, toBN, toIntegerString, toNumeric, toNumerics } from './convert';
|
|
6
|
+
export { formatValue } from './format';
|
|
7
|
+
export type { IFormatNumberOptions } from './format';
|
|
8
|
+
export { createArrayCompareFunction } from './helper';
|