big.esm 1.1.1 → 1.2.0
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/CHANGELOG.md +20 -0
- package/README.md +9 -54
- package/dist/big.d.ts +5 -5
- package/dist/big.esm.js +133 -93
- package/dist/big.esm.umd.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/operations/abs.d.ts +2 -1
- package/dist/operations/add.d.ts +2 -1
- package/dist/operations/div.d.ts +2 -1
- package/dist/operations/mod.d.ts +2 -1
- package/dist/operations/mul.d.ts +2 -1
- package/dist/operations/pow.d.ts +3 -2
- package/dist/operations/sqrt.d.ts +2 -1
- package/dist/operations/sub.d.ts +2 -1
- package/dist/types.d.ts +10 -1
- package/dist/utils/align-scale.d.ts +2 -1
- package/dist/utils/constants.d.ts +13 -0
- package/dist/utils/create.d.ts +5 -3
- package/dist/utils/from-string.d.ts +23 -0
- package/dist/utils/is-big-object.d.ts +20 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [1.2.0](https://github.com/dschewchenko/big.esm/compare/v1.1.2...v1.2.0) (2023-05-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add new utility functions: from-string, is-big-value ([3eb674e](https://github.com/dschewchenko/big.esm/commit/3eb674ed53345537db203136ebb5879f8235d37b))
|
|
7
|
+
* make mutable option for math operations ([267aaef](https://github.com/dschewchenko/big.esm/commit/267aaef28af70c7c39e015e961c027bf8786569b))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Performance Improvements
|
|
11
|
+
|
|
12
|
+
* optimize big instance init for some input types ([9e9ddd2](https://github.com/dschewchenko/big.esm/commit/9e9ddd21adb5590a19395da5fb0b9a5ee66378e4))
|
|
13
|
+
|
|
14
|
+
## [1.1.2](https://github.com/dschewchenko/big.esm/compare/v1.1.1...v1.1.2) (2023-05-14)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* benchmark update and readme notes ([7b8d446](https://github.com/dschewchenko/big.esm/commit/7b8d446be55eb0f0979ab310491e9bb685215753))
|
|
20
|
+
|
|
1
21
|
## [1.1.1](https://github.com/dschewchenko/big.esm/compare/v1.1.0...v1.1.1) (2023-05-14)
|
|
2
22
|
|
|
3
23
|
|
package/README.md
CHANGED
|
@@ -7,22 +7,20 @@ Library for working with large numbers and fractions using `BigInt`.
|
|
|
7
7
|
It provides advanced functionality for performing arithmetic operations with precision and decimal handling.
|
|
8
8
|
[Documentation](https://dschewchenko.github.io/big.esm/).
|
|
9
9
|
|
|
10
|
-
100% test coverage.
|
|
10
|
+
- 100% test coverage.
|
|
11
11
|
|
|
12
|
-
No dependencies.
|
|
12
|
+
- No dependencies.
|
|
13
13
|
|
|
14
|
-
No limitations on the size of the numbers, except for the limitations of `BigInt`, so limited by system memory =).
|
|
14
|
+
- No limitations on the size of the numbers, except for the limitations of `BigInt`, so limited by system memory =).
|
|
15
15
|
|
|
16
|
-
Fully written in TypeScript, so it provides type definitions out of the box.
|
|
16
|
+
- Fully written in TypeScript, so it provides type definitions out of the box.
|
|
17
17
|
|
|
18
|
-
Tree-shaking is supported.
|
|
18
|
+
- Tree-shaking is supported.
|
|
19
19
|
|
|
20
20
|
Full bundle size(ESM) — 3.12 kB minified and 1.42 kB gzipped.
|
|
21
21
|
`powBig` operation is half of this size, 1.5kB/0.7kB(minified/gzip),
|
|
22
22
|
because it's big and reuses most of the operations from `big.esm`.
|
|
23
23
|
|
|
24
|
-
Full bundle size(UMD) — 3.43 kB minified and 1.57 kB gzipped.
|
|
25
|
-
|
|
26
24
|
## Installation
|
|
27
25
|
|
|
28
26
|
Install `big.esm` using npm:
|
|
@@ -119,56 +117,13 @@ Compares two `Big` instances. Returns `-1` if `a < b`, `0` if `a == b` and `1` i
|
|
|
119
117
|
|
|
120
118
|
## Benchmark
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
| Operation | big.esm | big.js | Difference |
|
|
125
|
-
|--------------------------|-----------|------------|-----------------|
|
|
126
|
-
| init - smallInt | 39.856ms | 22.169ms | -79.78% slower |
|
|
127
|
-
| add - smallInt | 24.227ms | 15.125ms | -60.17% slower |
|
|
128
|
-
| subtract - smallInt | 22.181ms | 15.094ms | -46.95% slower |
|
|
129
|
-
| multiply - smallInt | 22.276ms | 18.538ms | -20.16% slower |
|
|
130
|
-
| divide - smallInt | 66.923ms | 179.699ms | 62.76% faster |
|
|
131
|
-
| power of 4 - smallInt | 113.714ms | 39.359ms | -188.92% slower |
|
|
132
|
-
| init - smallNumber | 44.606ms | 37.136ms | -20.12% slower |
|
|
133
|
-
| add - smallNumber | 21.719ms | 21.857ms | 0.63% faster |
|
|
134
|
-
| subtract - smallNumber | 21.090ms | 24.064ms | 12.36% faster |
|
|
135
|
-
| multiply - smallNumber | 23.246ms | 35.010ms | 33.60% faster |
|
|
136
|
-
| divide - smallNumber | 60.102ms | 189.603ms | 68.30% faster |
|
|
137
|
-
| power of 4 - smallNumber | 136.611ms | 68.859ms | -98.39% slower |
|
|
138
|
-
| init - bigInt | 50.278ms | 36.880ms | -36.33% slower |
|
|
139
|
-
| add - bigInt | 27.485ms | 25.402ms | -8.20% slower |
|
|
140
|
-
| subtract - bigInt | 27.402ms | 24.622ms | -11.29% slower |
|
|
141
|
-
| multiply - bigInt | 33.650ms | 121.126ms | 72.22% faster |
|
|
142
|
-
| divide - bigInt | 79.523ms | 602.879ms | 86.81% faster |
|
|
143
|
-
| power of 4 - bigInt | 248.514ms | 499.246ms | 50.22% faster |
|
|
144
|
-
| init - bigNumber | 55.661ms | 77.789ms | 28.45% faster |
|
|
145
|
-
| add - bigNumber | 29.755ms | 47.843ms | 37.81% faster |
|
|
146
|
-
| subtract - bigNumber | 29.107ms | 47.313ms | 38.48% faster |
|
|
147
|
-
| multiply - bigNumber | 39.976ms | 266.814ms | 85.02% faster |
|
|
148
|
-
| divide - bigNumber | 78.278ms | 931.610ms | 91.60% faster |
|
|
149
|
-
| power of 4 - bigNumber | 376.169ms | 1132.657ms | 66.79% faster |
|
|
150
|
-
|
|
151
|
-
#### Test data:
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
const smallIntA = 123;
|
|
155
|
-
const smallIntB = 456;
|
|
156
|
-
const smallNumberA = 123.456;
|
|
157
|
-
const smallNumberB = 789.012;
|
|
158
|
-
const bigIntA = "12345678901234567890";
|
|
159
|
-
const bigIntB = "67890123456789012345";
|
|
160
|
-
const bigNumberA = "12345678901234567890.1234567890";
|
|
161
|
-
const bigNumberB = "67890123456789012345.6789012345";
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Benchmarked on MacBook Pro M1 2021.
|
|
165
|
-
|
|
166
|
-
Code for benchmarking is in the `benchmark.js` file. You can run it with `npm run benchmark`.
|
|
120
|
+
Benchmark results are available [here](https://dschewchenko.github.io/big.esm/benchmark.html).
|
|
167
121
|
|
|
168
122
|
## Roadmap
|
|
169
123
|
|
|
170
124
|
- [x] Generate documentation from JSDoc
|
|
171
|
-
- [
|
|
125
|
+
- [x] Remove trailing zeros from toString method
|
|
126
|
+
- [ ] Add formatting options
|
|
172
127
|
- [ ] Add more mathematical functions
|
|
173
128
|
|
|
174
129
|
## License
|
|
@@ -177,4 +132,4 @@ MIT
|
|
|
177
132
|
|
|
178
133
|
## Copyright
|
|
179
134
|
|
|
180
|
-
© 2023 dschewchenko
|
|
135
|
+
© 2023 dschewchenko
|
package/dist/big.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PossibleNumber } from "./types";
|
|
1
|
+
import type { BigObject, PossibleNumber } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* The Big class for working with large numbers and fractions using BigInt.
|
|
4
4
|
*
|
|
@@ -18,19 +18,19 @@ export declare class Big {
|
|
|
18
18
|
/**
|
|
19
19
|
* The value of the Big instance.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
value: bigint;
|
|
22
22
|
/**
|
|
23
23
|
* The scale of the Big instance, representing the number of decimal places.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
scale: number;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a new Big instance.
|
|
28
28
|
*
|
|
29
|
-
* @param {Big} value - The value to create the Big instance from.
|
|
29
|
+
* @param {Big | BigObject} value - The value to create the Big instance from.
|
|
30
30
|
* @throws {TypeError} - If the value is not a number, string, BigInt, or Big instance.
|
|
31
31
|
* @return {Big} - A new Big instance.
|
|
32
32
|
*/
|
|
33
|
-
constructor(value: Big);
|
|
33
|
+
constructor(value: Big | BigObject);
|
|
34
34
|
/**
|
|
35
35
|
* Creates a new Big instance.
|
|
36
36
|
*
|
package/dist/big.esm.js
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var M = (e, t, n) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var I = (e, t, n) => (M(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
const D = (e) => typeof e == "bigint" || typeof e == "number" || typeof e == "string" && !isNaN(Number(e)), A = /0+$/, R = (e) => e.replace(A, "");
|
|
5
|
+
const B = BigInt(0), d = BigInt(1), p = BigInt(10);
|
|
6
|
+
function a(e, t) {
|
|
7
|
+
return e instanceof v ? e : new v(e, t);
|
|
8
|
+
}
|
|
9
|
+
function _(e, t = !1, n = !0) {
|
|
10
|
+
const r = typeof e == "number" ? e.toString() : e;
|
|
11
|
+
if (!isFinite(Number(r)))
|
|
12
|
+
throw new Error("Invalid number");
|
|
13
|
+
if (Number(r) === 0)
|
|
14
|
+
return n ? a(B) : { value: B, scale: 0 };
|
|
15
|
+
let [s, i] = r.split("e");
|
|
16
|
+
const g = s.startsWith("-") ? "-" : "";
|
|
17
|
+
g && (s = s.slice(1));
|
|
18
|
+
let [u, l = ""] = s.split(".");
|
|
19
|
+
t && (l = "");
|
|
20
|
+
const o = parseInt(i);
|
|
21
|
+
if (o > 0) {
|
|
22
|
+
const f = Math.min(o, l.length);
|
|
23
|
+
u += l.slice(0, f), l = l.slice(f), f < o && (u += "0".repeat(o - f));
|
|
24
|
+
} else if (o < 0) {
|
|
25
|
+
const f = Math.min(-o, u.length);
|
|
26
|
+
l = u.slice(-f) + l, u = u.slice(0, u.length - f), f < -o && (l = "0".repeat(-o - f) + l);
|
|
27
|
+
}
|
|
28
|
+
const h = BigInt(g + u + l), c = l.length;
|
|
29
|
+
return n ? a(h, c) : { value: h, scale: c };
|
|
30
|
+
}
|
|
31
|
+
function j(e) {
|
|
32
|
+
return e === null || typeof e != "object" ? !1 : "value" in e && "scale" in e && typeof e.value == "bigint" && typeof e.scale == "number";
|
|
33
|
+
}
|
|
34
|
+
class v {
|
|
7
35
|
/**
|
|
8
36
|
* Implements the overloaded constructors for the Big class.
|
|
9
37
|
* @param {BigValue} value - The value to create the Big instance from. Can be a number, string, BigInt, or another Big instance.
|
|
@@ -11,20 +39,25 @@ class B {
|
|
|
11
39
|
* @throws {TypeError} - If the value is not a number, string, BigInt, or Big instance.
|
|
12
40
|
* @return {Big} - A new Big instance.
|
|
13
41
|
*/
|
|
14
|
-
constructor(t,
|
|
42
|
+
constructor(t, n) {
|
|
15
43
|
/**
|
|
16
44
|
* The value of the Big instance.
|
|
17
45
|
*/
|
|
18
|
-
|
|
46
|
+
I(this, "value");
|
|
19
47
|
/**
|
|
20
48
|
* The scale of the Big instance, representing the number of decimal places.
|
|
21
49
|
*/
|
|
22
|
-
|
|
23
|
-
if (t instanceof
|
|
50
|
+
I(this, "scale");
|
|
51
|
+
if (t instanceof v || j(t))
|
|
24
52
|
this.value = t.value, this.scale = t.scale;
|
|
25
|
-
else if (
|
|
26
|
-
let
|
|
27
|
-
|
|
53
|
+
else if (D(t)) {
|
|
54
|
+
let r = n !== void 0;
|
|
55
|
+
if (r && (typeof n != "number" && (n = Number(n)), r = !isNaN(n), n = r ? Math.floor(n) : 0), typeof t == "bigint")
|
|
56
|
+
this.value = t, this.scale = r ? n : 0;
|
|
57
|
+
else {
|
|
58
|
+
const { value: s, scale: i } = _(t, r, !1);
|
|
59
|
+
this.value = s, this.scale = r ? n : i;
|
|
60
|
+
}
|
|
28
61
|
} else
|
|
29
62
|
throw new TypeError("Invalid type provided to Big constructor.");
|
|
30
63
|
}
|
|
@@ -43,15 +76,15 @@ class B {
|
|
|
43
76
|
* @return {string} - A string representation of the Big instance.
|
|
44
77
|
*/
|
|
45
78
|
toString(t = !0) {
|
|
46
|
-
let
|
|
47
|
-
const r =
|
|
48
|
-
r && (
|
|
49
|
-
let
|
|
50
|
-
if (this.scale >
|
|
51
|
-
const
|
|
52
|
-
|
|
79
|
+
let n = this.value.toString();
|
|
80
|
+
const r = n.startsWith("-") ? "-" : "";
|
|
81
|
+
r && (n = n.substring(1));
|
|
82
|
+
let s = "";
|
|
83
|
+
if (this.scale > B) {
|
|
84
|
+
const i = n.length > this.scale ? n.length - Number(this.scale) : 0;
|
|
85
|
+
s = n.slice(i).padStart(Number(this.scale), "0"), t && (s = R(s)), s.length > 0 && (s = `.${s}`), n = n.slice(0, i);
|
|
53
86
|
}
|
|
54
|
-
return `${r}${
|
|
87
|
+
return `${r}${n || "0"}${s}`;
|
|
55
88
|
}
|
|
56
89
|
/**
|
|
57
90
|
* Returns the JSON representation of the Big instance.
|
|
@@ -62,106 +95,113 @@ class B {
|
|
|
62
95
|
return this.toString();
|
|
63
96
|
}
|
|
64
97
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return [i, a];
|
|
98
|
+
function E(e, t, n = !1) {
|
|
99
|
+
const r = e.scale - t.scale;
|
|
100
|
+
if (r === 0)
|
|
101
|
+
return [e, t];
|
|
102
|
+
const s = p ** BigInt(Math.abs(r));
|
|
103
|
+
if (n)
|
|
104
|
+
return r > 0 ? (t.value *= s, t.scale = e.scale) : (e.value *= s, e.scale = t.scale), [e, t];
|
|
105
|
+
const i = r > 0 ? e : a(e.value * s, t.scale), g = r < 0 ? t : a(t.value * s, e.scale);
|
|
106
|
+
return [i, g];
|
|
75
107
|
}
|
|
76
|
-
function
|
|
77
|
-
const [
|
|
78
|
-
return
|
|
108
|
+
function y(e, t, n = !1) {
|
|
109
|
+
const [r, s] = E(e, t), i = r.value + s.value;
|
|
110
|
+
return n ? (e.value = i, e.scale = r.scale, e) : a(i, r.scale);
|
|
79
111
|
}
|
|
80
|
-
function
|
|
81
|
-
const [
|
|
82
|
-
return
|
|
112
|
+
function N(e, t, n = !1) {
|
|
113
|
+
const [r, s] = E(e, t, n), i = r.value - s.value;
|
|
114
|
+
return n ? (e.value = i, e) : a(i, r.scale);
|
|
83
115
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
return
|
|
116
|
+
function w(e, t, n = !1) {
|
|
117
|
+
const r = e.value * t.value, s = e.scale + t.scale;
|
|
118
|
+
return n ? (e.value = r, e.scale = s, e) : a(r, s);
|
|
87
119
|
}
|
|
88
|
-
const
|
|
89
|
-
function
|
|
90
|
-
if (
|
|
120
|
+
const S = (e) => e.value === B;
|
|
121
|
+
function m(e, t, n = 20, r = "half-up", s = !1) {
|
|
122
|
+
if (S(t))
|
|
91
123
|
throw new Error("Division by zero is not allowed.");
|
|
92
|
-
const i = Math.max(
|
|
93
|
-
let
|
|
124
|
+
const i = Math.max(e.scale, t.scale), g = Math.max(0, n), u = e.value * p ** BigInt(i + g - e.scale), l = t.value * p ** BigInt(i - t.scale), o = u / l, h = u % l;
|
|
125
|
+
let c;
|
|
94
126
|
switch (r) {
|
|
95
127
|
case "down":
|
|
96
|
-
|
|
128
|
+
c = o;
|
|
97
129
|
break;
|
|
98
130
|
case "up":
|
|
99
|
-
|
|
131
|
+
c = h !== B ? o + d : o + B;
|
|
100
132
|
break;
|
|
101
133
|
case "half-up":
|
|
102
134
|
default:
|
|
103
|
-
|
|
135
|
+
c = h * BigInt(2) >= l ? o + d : o;
|
|
104
136
|
break;
|
|
105
137
|
}
|
|
106
|
-
return
|
|
138
|
+
return s ? (e.value = c, e.scale = g, e) : a(c, g);
|
|
107
139
|
}
|
|
108
|
-
function
|
|
109
|
-
if (
|
|
140
|
+
function G(e, t, n = !1) {
|
|
141
|
+
if (S(t))
|
|
110
142
|
throw new Error("Division by zero is not allowed.");
|
|
111
|
-
const
|
|
112
|
-
|
|
143
|
+
const r = m(e, t, 0, "down");
|
|
144
|
+
if (n)
|
|
145
|
+
return w(r, t, !0), N(e, r, !0);
|
|
146
|
+
const s = w(r, t);
|
|
147
|
+
return N(e, s);
|
|
113
148
|
}
|
|
114
|
-
function
|
|
149
|
+
function b(e, t = 2, n = !1) {
|
|
115
150
|
if (!Number.isInteger(t) || t < 0)
|
|
116
151
|
throw new Error("The exponent must be a non-negative integer.");
|
|
117
|
-
let
|
|
152
|
+
let r = a(1), s = a(e);
|
|
118
153
|
for (t = Math.abs(t); t > 0; )
|
|
119
|
-
t % 2 === 1 && (
|
|
120
|
-
return e;
|
|
154
|
+
t % 2 === 1 && (r = w(r, s, n)), s = w(s, s, n), t = Math.floor(t / 2);
|
|
155
|
+
return n ? (e.value = r.value, e.scale = r.scale, e) : r;
|
|
121
156
|
}
|
|
122
|
-
const
|
|
123
|
-
const [
|
|
124
|
-
return
|
|
157
|
+
const P = (e, t) => {
|
|
158
|
+
const [n, r] = E(e, t);
|
|
159
|
+
return n.value > r.value ? 1 : n.value < r.value ? -1 : 0;
|
|
125
160
|
};
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
return
|
|
161
|
+
function $(e, t = !1) {
|
|
162
|
+
const n = e.value < B ? -e.value : e.value;
|
|
163
|
+
return t ? (e.value = n, e) : a(n, e.scale);
|
|
129
164
|
}
|
|
130
|
-
function
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
135
|
-
if (
|
|
165
|
+
function Z(e, t = 2, n = 20, r = !1) {
|
|
166
|
+
if (S(e))
|
|
167
|
+
return a(0);
|
|
168
|
+
if (e.valueOf() === BigInt(1))
|
|
169
|
+
return a(1);
|
|
170
|
+
if (e.value < B && t % 2 === 0)
|
|
136
171
|
throw new Error("The root must be an odd integer when the number is negative.");
|
|
137
172
|
if (!Number.isInteger(t) || t < 2)
|
|
138
173
|
throw new Error("The root must be an integer and greater than 1");
|
|
139
|
-
if (
|
|
174
|
+
if (n < 0)
|
|
140
175
|
throw new Error("The precision must be a non-negative integer.");
|
|
141
|
-
const
|
|
142
|
-
let
|
|
176
|
+
const s = a(n === 0 ? "1" : "0." + "0".repeat(n - 1) + "1"), i = a(t), g = a(t - 1), u = a(2);
|
|
177
|
+
let l = m(y(e, m(e, u, n)), u, n), o;
|
|
143
178
|
do {
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
} while (
|
|
148
|
-
const
|
|
149
|
-
|
|
179
|
+
o = l;
|
|
180
|
+
const T = y(w(g, l), m(e, b(l, t - 1), n));
|
|
181
|
+
l = m(T, i, n);
|
|
182
|
+
} while (P($(N(o, l)), s) === 1);
|
|
183
|
+
const h = l.toString();
|
|
184
|
+
if (r)
|
|
185
|
+
return e.value = l.value, e.scale = n, e;
|
|
186
|
+
const c = h.indexOf("."), f = c !== -1 ? h.slice(0, c + n + 1) : h;
|
|
187
|
+
return a(f);
|
|
150
188
|
}
|
|
151
|
-
const
|
|
189
|
+
const k = (e) => new v(e.value, e.scale);
|
|
152
190
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
191
|
+
v as Big,
|
|
192
|
+
$ as absBig,
|
|
193
|
+
y as addBig,
|
|
194
|
+
E as alignScale,
|
|
195
|
+
k as cloneBig,
|
|
196
|
+
P as compareBig,
|
|
197
|
+
a as createBig,
|
|
198
|
+
m as divBig,
|
|
199
|
+
_ as fromString,
|
|
200
|
+
j as isBigObject,
|
|
201
|
+
D as isNumericValue,
|
|
202
|
+
G as modBig,
|
|
203
|
+
w as mulBig,
|
|
204
|
+
b as powBig,
|
|
205
|
+
Z as sqrtBig,
|
|
206
|
+
N as subBig
|
|
167
207
|
};
|
package/dist/big.esm.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis<"u"?globalThis:s||self,c((s.big=s.big||{},s.big.esm={})))})(this,function(s){"use strict";var G=Object.defineProperty;var V=(s,c,d)=>c in s?G(s,c,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[c]=d;var O=(s,c,d)=>(V(s,typeof c!="symbol"?c+"":c,d),d);const c=e=>typeof e=="bigint"||typeof e=="number"||typeof e=="string"&&!isNaN(Number(e)),d=/0+$/,_=e=>e.replace(d,""),v=BigInt(0),b=BigInt(1),p=BigInt(10);function a(e,t){return e instanceof w?e:new w(e,t)}function M(e,t=!1,n=!0){const i=typeof e=="number"?e.toString():e;if(!isFinite(Number(i)))throw new Error("Invalid number");if(Number(i)===0)return n?a(v):{value:v,scale:0};let[r,u]=i.split("e");const B=r.startsWith("-")?"-":"";B&&(r=r.slice(1));let[f,l=""]=r.split(".");t&&(l="");const o=parseInt(u);if(o>0){const h=Math.min(o,l.length);f+=l.slice(0,h),l=l.slice(h),h<o&&(f+="0".repeat(o-h))}else if(o<0){const h=Math.min(-o,f.length);l=f.slice(-h)+l,f=f.slice(0,f.length-h),h<-o&&(l="0".repeat(-o-h)+l)}const m=BigInt(B+f+l),g=l.length;return n?a(m,g):{value:m,scale:g}}function j(e){return e===null||typeof e!="object"?!1:"value"in e&&"scale"in e&&typeof e.value=="bigint"&&typeof e.scale=="number"}class w{constructor(t,n){O(this,"value");O(this,"scale");if(t instanceof w||j(t))this.value=t.value,this.scale=t.scale;else if(c(t)){let i=n!==void 0;if(i&&(typeof n!="number"&&(n=Number(n)),i=!isNaN(n),n=i?Math.floor(n):0),typeof t=="bigint")this.value=t,this.scale=i?n:0;else{const{value:r,scale:u}=M(t,i,!1);this.value=r,this.scale=i?n:u}}else throw new TypeError("Invalid type provided to Big constructor.")}valueOf(){return this.value}toString(t=!0){let n=this.value.toString();const i=n.startsWith("-")?"-":"";i&&(n=n.substring(1));let r="";if(this.scale>v){const u=n.length>this.scale?n.length-Number(this.scale):0;r=n.slice(u).padStart(Number(this.scale),"0"),t&&(r=_(r)),r.length>0&&(r=`.${r}`),n=n.slice(0,u)}return`${i}${n||"0"}${r}`}toJSON(){return this.toString()}}function S(e,t,n=!1){const i=e.scale-t.scale;if(i===0)return[e,t];const r=p**BigInt(Math.abs(i));if(n)return i>0?(t.value*=r,t.scale=e.scale):(e.value*=r,e.scale=t.scale),[e,t];const u=i>0?e:a(e.value*r,t.scale),B=i<0?t:a(t.value*r,e.scale);return[u,B]}function y(e,t,n=!1){const[i,r]=S(e,t),u=i.value+r.value;return n?(e.value=u,e.scale=i.scale,e):a(u,i.scale)}function E(e,t,n=!1){const[i,r]=S(e,t,n),u=i.value-r.value;return n?(e.value=u,e):a(u,i.scale)}function I(e,t,n=!1){const i=e.value*t.value,r=e.scale+t.scale;return n?(e.value=i,e.scale=r,e):a(i,r)}const T=e=>e.value===v;function N(e,t,n=20,i="half-up",r=!1){if(T(t))throw new Error("Division by zero is not allowed.");const u=Math.max(e.scale,t.scale),B=Math.max(0,n),f=e.value*p**BigInt(u+B-e.scale),l=t.value*p**BigInt(u-t.scale),o=f/l,m=f%l;let g;switch(i){case"down":g=o;break;case"up":g=m!==v?o+b:o+v;break;case"half-up":default:g=m*BigInt(2)>=l?o+b:o;break}return r?(e.value=g,e.scale=B,e):a(g,B)}function P(e,t,n=!1){if(T(t))throw new Error("Division by zero is not allowed.");const i=N(e,t,0,"down");if(n)return I(i,t,!0),E(e,i,!0);const r=I(i,t);return E(e,r)}function D(e,t=2,n=!1){if(!Number.isInteger(t)||t<0)throw new Error("The exponent must be a non-negative integer.");let i=a(1),r=a(e);for(t=Math.abs(t);t>0;)t%2===1&&(i=I(i,r,n)),r=I(r,r,n),t=Math.floor(t/2);return n?(e.value=i.value,e.scale=i.scale,e):i}const A=(e,t)=>{const[n,i]=S(e,t);return n.value>i.value?1:n.value<i.value?-1:0};function R(e,t=!1){const n=e.value<v?-e.value:e.value;return t?(e.value=n,e):a(n,e.scale)}function $(e,t=2,n=20,i=!1){if(T(e))return a(0);if(e.valueOf()===BigInt(1))return a(1);if(e.value<v&&t%2===0)throw new Error("The root must be an odd integer when the number is negative.");if(!Number.isInteger(t)||t<2)throw new Error("The root must be an integer and greater than 1");if(n<0)throw new Error("The precision must be a non-negative integer.");const r=a(n===0?"1":"0."+"0".repeat(n-1)+"1"),u=a(t),B=a(t-1),f=a(2);let l=N(y(e,N(e,f,n)),f,n),o;do{o=l;const F=y(I(B,l),N(e,D(l,t-1),n));l=N(F,u,n)}while(A(R(E(o,l)),r)===1);const m=l.toString();if(i)return e.value=l.value,e.scale=n,e;const g=m.indexOf("."),h=g!==-1?m.slice(0,g+n+1):m;return a(h)}const q=e=>new w(e.value,e.scale);s.Big=w,s.absBig=R,s.addBig=y,s.alignScale=S,s.cloneBig=q,s.compareBig=A,s.createBig=a,s.divBig=N,s.fromString=M,s.isBigObject=j,s.isNumericValue=c,s.modBig=P,s.mulBig=I,s.powBig=D,s.sqrtBig=$,s.subBig=E,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export { powBig } from "./operations/pow";
|
|
|
9
9
|
export { sqrtBig } from "./operations/sqrt";
|
|
10
10
|
export { absBig } from "./operations/abs";
|
|
11
11
|
export { compareBig } from "./operations/compare";
|
|
12
|
+
export { isBigObject } from "./utils/is-big-object";
|
|
12
13
|
export { isNumericValue } from "./utils/numeric";
|
|
13
14
|
export { alignScale } from "./utils/align-scale";
|
|
14
15
|
export { createBig } from "./utils/create.ts";
|
|
15
16
|
export { cloneBig } from "./utils/clone.ts";
|
|
17
|
+
export { fromString } from "./utils/from-string.ts";
|
package/dist/operations/abs.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Big } from "../big";
|
|
|
3
3
|
* Returns the absolute value of a Big instance.
|
|
4
4
|
*
|
|
5
5
|
* @param {Big} big - The Big instance.
|
|
6
|
+
* @param {boolean} [mutable=false] - Whether to mutate the Big instance. Defaults to false.
|
|
6
7
|
* @returns {Big} The absolute value of the Big instance.
|
|
7
8
|
*
|
|
8
9
|
* @category Operations
|
|
@@ -12,4 +13,4 @@ import type { Big } from "../big";
|
|
|
12
13
|
* absBig(new Big(-1.1)); // new Big instance with value 1.1
|
|
13
14
|
* absBig(new Big(1)); // new Big instance with value 1
|
|
14
15
|
*/
|
|
15
|
-
export declare function absBig(big: Big): Big;
|
|
16
|
+
export declare function absBig(big: Big, mutable?: boolean): Big;
|
package/dist/operations/add.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Big } from "../big";
|
|
|
4
4
|
*
|
|
5
5
|
* @param {Big} a - The first value to add.
|
|
6
6
|
* @param {Big} b - The second value to add.
|
|
7
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first value. Defaults to false.
|
|
7
8
|
* @returns {Big} The sum of the two values.
|
|
8
9
|
*
|
|
9
10
|
* @category Operations
|
|
@@ -13,4 +14,4 @@ import type { Big } from "../big";
|
|
|
13
14
|
* addBig(new Big(1.1), new Big(2.2)); // new Big instance with value 3.3
|
|
14
15
|
* addBig(new Big(1.1), new Big(2)); // new Big instance with value 3.1
|
|
15
16
|
*/
|
|
16
|
-
export declare function addBig(a: Big, b: Big): Big;
|
|
17
|
+
export declare function addBig(a: Big, b: Big, mutable?: boolean): Big;
|
package/dist/operations/div.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Big } from "../big";
|
|
|
7
7
|
* @param {Big} divisor - The divisor Big instance.
|
|
8
8
|
* @param {number} [precision] - The number of decimal places to keep in the result (optional). Defaults to the maximum scale of both Big instances. If the precision is lower than the scale of the result, the result will be rounded. If input numbers are without scale, the precision will be 0, so the result will be rounded to an integer.
|
|
9
9
|
* @param {string} [roundingMode="half-up"] - The rounding mode to apply ("half-up", "down" or "up"). Defaults to "half-up".
|
|
10
|
+
* @param {boolean} [mutable=false] - Whether to mutate the dividend or not. Defaults to false.
|
|
10
11
|
* @returns {Big} - A new Big instance representing the result of the division.
|
|
11
12
|
* @throws {Error} Division by zero is not allowed.
|
|
12
13
|
*
|
|
@@ -21,4 +22,4 @@ import type { Big } from "../big";
|
|
|
21
22
|
* console.log(divBig(big1, big2, 2, "down").toString()); // "3.33"
|
|
22
23
|
* console.log(divBig(big1, big2, 2, "up").toString()); // "3.34"
|
|
23
24
|
*/
|
|
24
|
-
export declare function divBig(dividend: Big, divisor: Big, precision?: number, roundingMode?: RoundingMode): Big;
|
|
25
|
+
export declare function divBig(dividend: Big, divisor: Big, precision?: number, roundingMode?: RoundingMode, mutable?: boolean): Big;
|
package/dist/operations/mod.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Big } from "../big";
|
|
|
4
4
|
*
|
|
5
5
|
* @param dividend The Big instance representing the dividend.
|
|
6
6
|
* @param divisor The Big instance representing the divisor.
|
|
7
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first Big instance. Defaults to false.
|
|
7
8
|
* @returns A new Big instance representing the remainder of the division.
|
|
8
9
|
* @throws {Error} Division by zero is not allowed.
|
|
9
10
|
*
|
|
@@ -16,4 +17,4 @@ import type { Big } from "../big";
|
|
|
16
17
|
* console.log(modBig(big2, big1).toString()); // "3"
|
|
17
18
|
* console.log(modBig(big1, big1).toString()); // "0"
|
|
18
19
|
*/
|
|
19
|
-
export declare function modBig(dividend: Big, divisor: Big): Big;
|
|
20
|
+
export declare function modBig(dividend: Big, divisor: Big, mutable?: boolean): Big;
|
package/dist/operations/mul.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Big } from "../big";
|
|
|
4
4
|
*
|
|
5
5
|
* @param {Big} a - The first Big instance.
|
|
6
6
|
* @param {Big} b - The second Big instance.
|
|
7
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first Big instance. Defaults to false.
|
|
7
8
|
* @returns {Big} The result of the multiplication.
|
|
8
9
|
*
|
|
9
10
|
* @category Operations
|
|
@@ -13,4 +14,4 @@ import type { Big } from "../big";
|
|
|
13
14
|
* mulBig(new Big(1.1), new Big(2.2)); // new Big instance with value 2.42
|
|
14
15
|
* mulBig(new Big(1.1), new Big(2)); // new Big instance with value 2.2
|
|
15
16
|
*/
|
|
16
|
-
export declare function mulBig(a: Big, b: Big): Big;
|
|
17
|
+
export declare function mulBig(a: Big, b: Big, mutable?: boolean): Big;
|
package/dist/operations/pow.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { Big } from "../big";
|
|
|
3
3
|
* Raises a Big number to the power of another Big number.
|
|
4
4
|
*
|
|
5
5
|
* @param {Big} big - The base Big number.
|
|
6
|
-
* @param {number} exp - The exponent (non-negative integer).
|
|
6
|
+
* @param {number} exp - The exponent (non-negative integer). Defaults to 2.
|
|
7
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first Big instance. Defaults to false.
|
|
7
8
|
* @returns {Big} - The result of a raised to the power of b.
|
|
8
9
|
* @throws {Error} - If the exponent is not a non-negative integer.
|
|
9
10
|
*
|
|
@@ -16,4 +17,4 @@ import type { Big } from "../big";
|
|
|
16
17
|
* powBig(new Big(2), 3.3); // throws Error
|
|
17
18
|
* powBig(new Big(2), -3); // throws Error
|
|
18
19
|
*/
|
|
19
|
-
export declare function powBig(big: Big, exp
|
|
20
|
+
export declare function powBig(big: Big, exp?: number, mutable?: boolean): Big;
|
|
@@ -7,6 +7,7 @@ import type { Big } from "../big";
|
|
|
7
7
|
* @param {Big} big - The Big instance.
|
|
8
8
|
* @param {number} root - The root to calculate. Must be an integer. Defaults to 2.
|
|
9
9
|
* @param {number} precision - The number of decimal places to keep in the result (optional). Defaults to 20.
|
|
10
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first Big instance. Defaults to false.
|
|
10
11
|
* @returns {Big} The nth root of the Big instance with the specified precision and rounding mode.
|
|
11
12
|
* @throws {Error} - If the root is not an integer.
|
|
12
13
|
*
|
|
@@ -24,4 +25,4 @@ import type { Big } from "../big";
|
|
|
24
25
|
* console.log(sqrtBig(Big(16), -2).toString()); // throws Error
|
|
25
26
|
* console.log(sqrtBig(Big(16), 4, -1).toString()); // throws Error
|
|
26
27
|
*/
|
|
27
|
-
export declare function sqrtBig(big: Big, root?: number, precision?: number): Big;
|
|
28
|
+
export declare function sqrtBig(big: Big, root?: number, precision?: number, mutable?: boolean): Big;
|
package/dist/operations/sub.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Big } from "../big";
|
|
|
4
4
|
*
|
|
5
5
|
* @param {Big} a - The first Big instance.
|
|
6
6
|
* @param {Big} b - The second Big instance.
|
|
7
|
+
* @param {boolean} [mutable=false] - Whether to mutate the first Big instance. Defaults to false.
|
|
7
8
|
* @returns {Big} The result of the subtraction.
|
|
8
9
|
*
|
|
9
10
|
* @category Operations
|
|
@@ -12,4 +13,4 @@ import type { Big } from "../big";
|
|
|
12
13
|
* subBig(new Big(1), new Big(2)); // new Big instance with value -1
|
|
13
14
|
* subBig(new Big(1.1), new Big(2.2)); // new Big instance with value -1.1
|
|
14
15
|
*/
|
|
15
|
-
export declare function subBig(a: Big, b: Big): Big;
|
|
16
|
+
export declare function subBig(a: Big, b: Big, mutable?: boolean): Big;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Big } from "./big";
|
|
2
|
+
/**
|
|
3
|
+
* The object type for the Big class.
|
|
4
|
+
*
|
|
5
|
+
* @category Types
|
|
6
|
+
*/
|
|
7
|
+
export type BigObject = {
|
|
8
|
+
value: bigint;
|
|
9
|
+
scale: number;
|
|
10
|
+
};
|
|
2
11
|
/**
|
|
3
12
|
* Possible number types for processing.
|
|
4
13
|
*
|
|
@@ -10,7 +19,7 @@ export type PossibleNumber = number | string | bigint;
|
|
|
10
19
|
*
|
|
11
20
|
* @category Types
|
|
12
21
|
*/
|
|
13
|
-
export type BigValue = PossibleNumber | Big;
|
|
22
|
+
export type BigValue = PossibleNumber | Big | BigObject;
|
|
14
23
|
/**
|
|
15
24
|
* The rounding mode for division operations.
|
|
16
25
|
*
|
|
@@ -9,6 +9,7 @@ import type { Big } from "../big";
|
|
|
9
9
|
*
|
|
10
10
|
* @param {Big} a - The first Big instance.
|
|
11
11
|
* @param {Big} b - The second Big instance.
|
|
12
|
+
* @param {boolean} [mutable=false] - Whether to mutate the both Big instances. Defaults to false.
|
|
12
13
|
* @returns {[Big, Big]} A tuple of two Big instances with the same scale.
|
|
13
14
|
*
|
|
14
15
|
* @category Utilities
|
|
@@ -20,4 +21,4 @@ import type { Big } from "../big";
|
|
|
20
21
|
* console.log(x.toString()); // "123.456000"
|
|
21
22
|
* console.log(y.toString()); // "123.456789"
|
|
22
23
|
*/
|
|
23
|
-
export declare function alignScale(a: Big, b: Big): [Big, Big];
|
|
24
|
+
export declare function alignScale(a: Big, b: Big, mutable?: boolean): [Big, Big];
|
|
@@ -10,3 +10,16 @@ export declare const DEFAULT_PRECISION = 20;
|
|
|
10
10
|
* @category Constants
|
|
11
11
|
*/
|
|
12
12
|
export declare const ZERO_BIGINT: bigint;
|
|
13
|
+
/**
|
|
14
|
+
* One as a BigInt.
|
|
15
|
+
*
|
|
16
|
+
* @category Constants
|
|
17
|
+
*/
|
|
18
|
+
export declare const ONE_BIGINT: bigint;
|
|
19
|
+
/**
|
|
20
|
+
* Ten as a BigInt.
|
|
21
|
+
* Often used as scale multiplier to adjust the scale of a Big instance.
|
|
22
|
+
*
|
|
23
|
+
* @category Constants
|
|
24
|
+
*/
|
|
25
|
+
export declare const TEN_BIGINT: bigint;
|
package/dist/utils/create.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Big } from "../big.ts";
|
|
2
|
-
import type { PossibleNumber } from "../types.ts";
|
|
2
|
+
import type { BigObject, PossibleNumber } from "../types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new Big instance from the given value.
|
|
5
5
|
* If the value is already a Big instance, it returns the value itself.
|
|
6
6
|
* Use this function instead of the Big constructor to create a Big instance from a value.
|
|
7
7
|
*
|
|
8
|
-
* @param {Big} value - The value to create the Big instance from.
|
|
8
|
+
* @param {Big | BigObject} value - The value to create the Big instance from.
|
|
9
9
|
* @return {Big} - A new Big instance.
|
|
10
10
|
*/
|
|
11
|
-
export declare function createBig(value: Big): Big;
|
|
11
|
+
export declare function createBig(value: Big | BigObject): Big;
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new Big instance from the given value.
|
|
14
14
|
* If the value is already a Big instance, it returns the value itself.
|
|
@@ -27,6 +27,8 @@ export declare function createBig(value: PossibleNumber): Big;
|
|
|
27
27
|
* @param {number | string | undefined} [scale] - The scale for the value (optional), representing the number of decimal places. If scale provided and value has a fractional part, the fractional part will be removed.
|
|
28
28
|
* @return {Big} - A new Big instance.
|
|
29
29
|
*
|
|
30
|
+
* @category Utilities
|
|
31
|
+
*
|
|
30
32
|
* @example
|
|
31
33
|
* const big1 = createBig(123.456); // 123.456
|
|
32
34
|
* const big2 = createBig("123.456"); // 123.456
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Big } from "../big.ts";
|
|
2
|
+
import { BigObject } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a number or string to normal string number. Supports scientific notation.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | number} num - The number to convert
|
|
7
|
+
* @param {boolean} [ignoreFraction=false] - Whether to ignore the fractional part of the number. Defaults to false.
|
|
8
|
+
* @param {boolean} [returnInstance=false] - Whether to return a Big instance or BigObject. Defaults to true.
|
|
9
|
+
*
|
|
10
|
+
* @return {Big | BigObject} - A Big instance or BigObject representing the number
|
|
11
|
+
* @throws {Error} - If the number is too big or too small
|
|
12
|
+
* @throws {Error} - If the number is invalid
|
|
13
|
+
*
|
|
14
|
+
* @category Utilities
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* fromString("123.456"); // Big { value: 123456n, scale: 3 }
|
|
18
|
+
* fromString("123.456", true); // Big { value: 123n, scale: 0 }
|
|
19
|
+
* fromString("123.456", false, false); // { value: 123456n, scale: 3 }
|
|
20
|
+
* fromString("1.5e3"); // Big { value: 1500n, scale: 0 }
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromString<Type extends boolean>(num: string | number, ignoreFraction?: boolean, returnInstance?: Type): Type extends true ? Big : BigObject;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BigObject } from "../types.ts";
|
|
2
|
+
import type { Big } from "../big.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Determines if the value is a BigObject. A BigObject is an object with a value property of type bigint and a scale property of type number. It usually represents a Big instance.
|
|
5
|
+
*
|
|
6
|
+
* @param {Big | BigObject} value - The value to check. Can be a Big instance or a BigObject.
|
|
7
|
+
* @return {boolean} - True if the value is a BigObject, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @category Utilities
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* isBigObject({ value: 123456n, scale: 2 }); // true
|
|
13
|
+
* isBigObject({ value: 123456n, scale: 2, foo: "bar" }); // true
|
|
14
|
+
* isBigObject({ value: 123456n }); // false
|
|
15
|
+
* isBigObject({ scale: 2 }); // false
|
|
16
|
+
* isBigObject({}); // false
|
|
17
|
+
* isBigObject(123456n); // false
|
|
18
|
+
* isBigObject({ value: "abc", scale: "2"}); // false
|
|
19
|
+
*/
|
|
20
|
+
export declare function isBigObject(value: Big | BigObject | unknown): value is BigObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "big.esm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A small, fast JavaScript library for arbitrary-precision decimal arithmetic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"test:ui": "vitest --ui",
|
|
12
12
|
"test:run": "vitest run",
|
|
13
13
|
"coverage": "vitest run --coverage",
|
|
14
|
-
"docs": "typedoc --out docs
|
|
14
|
+
"docs": "typedoc --out docs",
|
|
15
15
|
"lint": "eslint --ext .ts,.js,.json ./src",
|
|
16
16
|
"lint:fix": "eslint --fix --ext .ts,.js,.json ./src",
|
|
17
|
-
"benchmark": "node ./benchmark.js",
|
|
17
|
+
"benchmark": "node --expose-gc ./benchmark.js",
|
|
18
18
|
"semantic-release": "semantic-release",
|
|
19
19
|
"prepare": "is-ci || husky install"
|
|
20
20
|
},
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"node": ">=16"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"big.js": "^6.2.1",
|
|
54
53
|
"@commitlint/cli": "^17.6.3",
|
|
55
54
|
"@commitlint/config-conventional": "^17.6.3",
|
|
56
55
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -61,6 +60,7 @@
|
|
|
61
60
|
"@typescript-eslint/parser": "^5.59.5",
|
|
62
61
|
"@vitest/coverage-c8": "^0.31.0",
|
|
63
62
|
"@vitest/ui": "^0.31.0",
|
|
63
|
+
"big.js": "^6.2.1",
|
|
64
64
|
"eslint": "^8.40.0",
|
|
65
65
|
"eslint-config-prettier": "^8.8.0",
|
|
66
66
|
"eslint-plugin-prettier": "^4.2.1",
|