@numio/bigmath 2.3.2 → 2.4.1
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 +6 -0
- package/README.md +5 -4
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +3 -2
- package/src/mod/mod.d.ts +2 -0
- package/src/mod/mod.js +11 -0
- package/src/mod/types.d.ts +3 -0
- package/src/mod/utils.d.ts +2 -0
- package/src/mod/utils.js +3 -0
- package/src/operations/add/add.js +1 -1
- package/src/pipe/pipe.d.ts +1 -0
- package/src/pipe/pipe.js +8 -0
- package/src/shared/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
@@ -5,11 +5,10 @@
|
|
5
5
|
|
6
6
|
## Latest Update
|
7
7
|
|
8
|
-
This update introduces
|
8
|
+
This update introduces new functionalities:
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
- **Median Absolute Deviation (MAD):** Implemented calculation for the Median Absolute Deviation, allowing users to compute it based on either the `median` or the `mean` of the dataset.
|
10
|
+
* **Modulo Operation (`mod`):** A new `mod` function has been added for performing modulo operations.
|
11
|
+
* **Pipe Function Enhancement:** The `mod` function has been integrated into the `Pipe` function for seamless chaining of operations.
|
13
12
|
|
14
13
|
## Existing Functionality
|
15
14
|
|
@@ -32,6 +31,7 @@ The application currently supports the following operations:
|
|
32
31
|
- `min`: Finding the minimum value in a dataset.
|
33
32
|
- `MAD`: Calculating the Median Absolute Deviation (based on either median or mean).
|
34
33
|
- `IQR`: Calculating the Interquartile Range.
|
34
|
+
- `FDR`: Freedman-Diaconis rule
|
35
35
|
- **Comparison:**
|
36
36
|
- `isEqual`: Checking if two values are equal.
|
37
37
|
- `isLeftGreater`: Checking if the left value is greater than the right value.
|
@@ -40,6 +40,7 @@ The application currently supports the following operations:
|
|
40
40
|
- `sqrt`: Calculating the square root of a number.
|
41
41
|
- `cbrt`: Calculating the cube root of a number.
|
42
42
|
- `abs`: Calculating the absolute value of a number.
|
43
|
+
- `mod`: Modulo operation, which finds the remainder when one number is divided by another
|
43
44
|
- **Number Base Conversion:**
|
44
45
|
- `toBase`: Converting a number to a specified base.
|
45
46
|
- `isHex`: Checking if a string is a valid hexadecimal number.
|
package/index.d.ts
CHANGED
@@ -24,4 +24,5 @@ import { isDecimal } from "./src/isValid/isDecimal.d.ts";
|
|
24
24
|
import { isOctal } from "./src/isValid/isOctal.d.ts";
|
25
25
|
import { isNumber } from "./src/isValid/isNumber.d.ts";
|
26
26
|
import { FDR } from "./src/FDR/fdr.d.ts";
|
27
|
-
|
27
|
+
import { mod } from "./src/mod/mod.d.ts";
|
28
|
+
export { abs, add, cbrt, div, IQR, isEqual, isLeftGreater, isLeftGreaterOrEqual, MAD, max, mean, min, mul, Pipe, quartile, round, sort, sqrt, sub, toBase, isHex, isBinary, isDecimal, isOctal, isNumber, FDR, mod };
|
package/index.js
CHANGED
@@ -24,4 +24,5 @@ import { isDecimal } from "./src/isValid/isDecimal.js";
|
|
24
24
|
import { isOctal } from "./src/isValid/isOctal.js";
|
25
25
|
import { isNumber } from "./src/isValid/isNumber.js";
|
26
26
|
import { FDR } from "./src/FDR/fdr.js";
|
27
|
-
|
27
|
+
import { mod } from "./src/mod/mod.js";
|
28
|
+
export { abs, add, cbrt, div, IQR, isEqual, isLeftGreater, isLeftGreaterOrEqual, MAD, max, mean, min, mul, Pipe, quartile, round, sort, sqrt, sub, toBase, isHex, isBinary, isDecimal, isOctal, isNumber, FDR, mod };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@numio/bigmath",
|
3
3
|
"description": "@numio/bigmath is an arbitrary-precision arithmetic library. It can be used for basic operations with decimal numbers (integers and float)",
|
4
|
-
"version": "2.
|
4
|
+
"version": "2.4.1",
|
5
5
|
"keywords": [
|
6
6
|
"precision",
|
7
7
|
"arithmetic",
|
@@ -54,7 +54,8 @@
|
|
54
54
|
"binary",
|
55
55
|
"cube root",
|
56
56
|
"FDR",
|
57
|
-
"Freedman-Diaconis Rule"
|
57
|
+
"Freedman-Diaconis Rule",
|
58
|
+
"mod"
|
58
59
|
],
|
59
60
|
"repository": {
|
60
61
|
"type": "git",
|
package/src/mod/mod.d.ts
ADDED
package/src/mod/mod.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import { bi2s, s2bi } from "../shared/utils.js";
|
2
|
+
import { modInner } from "./utils.js";
|
3
|
+
export const mod = (left, right) => {
|
4
|
+
const bil = s2bi(left);
|
5
|
+
const bir = s2bi(right);
|
6
|
+
if (bil[1] > 0)
|
7
|
+
throw new Error(`${left} is no valid. It should be integer`);
|
8
|
+
if (bir[1] > 0)
|
9
|
+
throw new Error(`${right} is no valid. It should be integer`);
|
10
|
+
return bi2s(modInner(bil, bir));
|
11
|
+
};
|
package/src/mod/utils.js
ADDED
package/src/pipe/pipe.d.ts
CHANGED
package/src/pipe/pipe.js
CHANGED
@@ -13,6 +13,7 @@ var _Pipe_result;
|
|
13
13
|
import { bi2s, calcInner, s2bi } from "../shared/utils.js";
|
14
14
|
import { divInner } from "../operations/div/utils.js";
|
15
15
|
import { absInner } from "../abs/utils.js";
|
16
|
+
import { modInner } from "../mod/utils.js";
|
16
17
|
/** Using this function you can chain operations (add, sub, div, mul). */
|
17
18
|
export class Pipe {
|
18
19
|
constructor(value) {
|
@@ -46,6 +47,13 @@ export class Pipe {
|
|
46
47
|
__classPrivateFieldSet(this, _Pipe_result, absInner(__classPrivateFieldGet(this, _Pipe_result, "f")), "f");
|
47
48
|
return this;
|
48
49
|
}
|
50
|
+
mod(value) {
|
51
|
+
if (!__classPrivateFieldGet(this, _Pipe_result, "f")) {
|
52
|
+
throw new Error("Value is undefined.");
|
53
|
+
}
|
54
|
+
__classPrivateFieldSet(this, _Pipe_result, modInner(__classPrivateFieldGet(this, _Pipe_result, "f"), s2bi(value)), "f");
|
55
|
+
return this;
|
56
|
+
}
|
49
57
|
calc() {
|
50
58
|
if (!__classPrivateFieldGet(this, _Pipe_result, "f")) {
|
51
59
|
throw new Error("Cannot calculate based on an undefined input.");
|
package/src/shared/types.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export type BI = [bigint, number];
|
2
|
+
export type Input = string[];
|
2
3
|
export type FillHead = (len: number, fpe: number, isNeg: boolean, hasBefore: boolean) => string;
|
3
4
|
export type TrimTail = (str: string) => string;
|
4
5
|
export type CalcInner = (array: BI[], op: (a: bigint, b: bigint) => bigint, def?: BI) => BI;
|