@numio/bigmath 1.0.4 → 1.0.5

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.
Files changed (32) hide show
  1. package/README.md +13 -1
  2. package/index.d.ts +6 -5
  3. package/index.js +6 -5
  4. package/package.json +7 -2
  5. package/src/{add → mathOperations/add}/index.js +2 -2
  6. package/src/{add → mathOperations/add}/types.d.ts +1 -1
  7. package/src/mathOperations/add/utils.d.ts +5 -0
  8. package/src/{div → mathOperations/div}/index.js +2 -2
  9. package/src/mathOperations/div/types.d.ts +3 -0
  10. package/src/mathOperations/div/utils.d.ts +3 -0
  11. package/src/{mul → mathOperations/mul}/index.js +2 -2
  12. package/src/{mul → mathOperations/mul}/types.d.ts +1 -1
  13. package/src/{mul → mathOperations/mul}/utils.d.ts +2 -2
  14. package/src/{sub → mathOperations/sub}/index.js +2 -2
  15. package/src/{sub → mathOperations/sub}/types.d.ts +1 -1
  16. package/src/{sub → mathOperations/sub}/utils.d.ts +2 -2
  17. package/src/pipe/main.js +4 -4
  18. package/src/quartile/main.d.ts +2 -0
  19. package/src/quartile/main.js +19 -0
  20. package/src/quartile/types.d.ts +6 -0
  21. package/src/types.d.ts +1 -0
  22. package/src/add/utils.d.ts +0 -5
  23. package/src/div/types.d.ts +0 -2
  24. package/src/div/utils.d.ts +0 -4
  25. /package/src/{add → mathOperations/add}/index.d.ts +0 -0
  26. /package/src/{add → mathOperations/add}/utils.js +0 -0
  27. /package/src/{div → mathOperations/div}/index.d.ts +0 -0
  28. /package/src/{div → mathOperations/div}/utils.js +0 -0
  29. /package/src/{mul → mathOperations/mul}/index.d.ts +0 -0
  30. /package/src/{mul → mathOperations/mul}/utils.js +0 -0
  31. /package/src/{sub → mathOperations/sub}/index.d.ts +0 -0
  32. /package/src/{sub → mathOperations/sub}/utils.js +0 -0
package/README.md CHANGED
@@ -50,7 +50,9 @@ large numbers are essential, such as:
50
50
 
51
51
  ### Latest update
52
52
 
53
- Added pipe functionality
53
+ Added quartile functionality. When you might need it?
54
+ Understanding Distribution. Quartiles (Q1, Q2, and Q3) split a dataset into four groups, each representing 25% of the data.
55
+ Identifying Outliers. They help visualize the shape and spread of the data, revealing whether it's skewed or symmetrical.
54
56
 
55
57
  # Install:
56
58
 
@@ -211,6 +213,16 @@ pipe.add(addNums) // 6
211
213
  .calc()
212
214
  ```
213
215
 
216
+ ### Quartile
217
+ ```javascript
218
+ import { quartile } from "@numio/bigmath";
219
+
220
+ quartile(["1", "2", "3", "4", "5", "6", "7", "8", "9"]) // { Q1: "2.5", Q2: "5", Q3: "7.5" }
221
+ quartile(["0.001", "0.3", "0.4", "1"]) // { Q1: "0.1505", Q2: "0.35", Q3: "0.7" }
222
+
223
+ ```
224
+
225
+
214
226
  Does not have a limitation on the number of digits. You can use any length you'd
215
227
  like
216
228
 
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { add } from "./src/add/index.d.ts";
2
- import { mul } from "./src/mul/index.d.ts";
3
- import { sub } from "./src/sub/index.d.ts";
4
- import { div } from "./src/div/index.d.ts";
1
+ import { add } from "./src/mathOperations/add/index.d.ts";
2
+ import { mul } from "./src/mathOperations/mul/index.d.ts";
3
+ import { sub } from "./src/mathOperations/sub/index.d.ts";
4
+ import { div } from "./src/mathOperations/div/index.d.ts";
5
5
  import { round } from "./src/round/index.d.ts";
6
6
  import { pipe } from "./src/pipe/main.d.ts";
7
- export { add, div, mul, round, sub, pipe };
7
+ import { quartile } from "./src/quartile/main.d.ts";
8
+ export { add, div, mul, pipe, quartile, round, sub };
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { add } from "./src/add/index.js";
2
- import { mul } from "./src/mul/index.js";
3
- import { sub } from "./src/sub/index.js";
4
- import { div } from "./src/div/index.js";
1
+ import { add } from "./src/mathOperations/add/index.js";
2
+ import { mul } from "./src/mathOperations/mul/index.js";
3
+ import { sub } from "./src/mathOperations/sub/index.js";
4
+ import { div } from "./src/mathOperations/div/index.js";
5
5
  import { round } from "./src/round/index.js";
6
6
  import { pipe } from "./src/pipe/main.js";
7
- export { add, div, mul, round, sub, pipe };
7
+ import { quartile } from "./src/quartile/main.js";
8
+ export { add, div, mul, pipe, quartile, round, sub };
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": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "keywords": [
6
6
  "precision",
7
7
  "arithmetic",
@@ -28,7 +28,12 @@
28
28
  "divide",
29
29
  "long division",
30
30
  "bigmath",
31
- "numio"
31
+ "numio",
32
+ "quartile",
33
+ "Q1",
34
+ "Q2",
35
+ "Q3",
36
+ "round"
32
37
  ],
33
38
  "repository": {
34
39
  "type": "git",
@@ -1,5 +1,5 @@
1
- import { DEFAULT } from "../shared/constant.js";
2
- import { a2s, s2a } from "../shared/utils.js";
1
+ import { DEFAULT } from "../../shared/constant.js";
2
+ import { a2s, s2a } from "../../shared/utils.js";
3
3
  import { addRoute } from "./utils.js";
4
4
  /** This function adds numbers (as string). */
5
5
  export function add(strs) {
@@ -1,2 +1,2 @@
1
- import type { InputData } from "../types.d.ts";
1
+ import type { InputData } from "../../types.d.ts";
2
2
  export type Addition = (L: [number[], number], R: [number[], number], isNegative: boolean) => InputData;
@@ -0,0 +1,5 @@
1
+ import type { Route } from "../../types.d.ts";
2
+ import type { Addition } from "./types.d.ts";
3
+ /** This function adds 2 numbers (as array). */
4
+ export declare const addition: Addition;
5
+ export declare const addRoute: Route;
@@ -1,5 +1,5 @@
1
- import { DEFAULT } from "../shared/constant.js";
2
- import { a2s, s2a } from "../shared/utils.js";
1
+ import { DEFAULT } from "../../shared/constant.js";
2
+ import { a2s, s2a } from "../../shared/utils.js";
3
3
  import { divRoute } from "./utils.js";
4
4
  /** This function should divide numbers (as string). */
5
5
  export var div = function (strs, limit) {
@@ -0,0 +1,3 @@
1
+ import type { InputData } from "../../types.d.ts";
2
+ export type Division = (L: [number[], number], R: [number[], number], isNegative: boolean, initLimit: number) => InputData;
3
+ export type DivRoute = (input: InputData[], initValue: InputData, limit: number) => InputData;
@@ -0,0 +1,3 @@
1
+ import type { Division, DivRoute } from "./types.d.ts";
2
+ export declare const division: Division;
3
+ export declare const divRoute: DivRoute;
@@ -1,5 +1,5 @@
1
- import { DEFAULT } from "../shared/constant.js";
2
- import { a2s, s2a } from "../shared/utils.js";
1
+ import { DEFAULT } from "../../shared/constant.js";
2
+ import { a2s, s2a } from "../../shared/utils.js";
3
3
  import { mulRoute } from "./utils.js";
4
4
  /** This function multiplies numbers (as string). */
5
5
  export var mul = function (strs) {
@@ -1,2 +1,2 @@
1
- import type { InputData } from "../types.d.ts";
1
+ import type { InputData } from "../../types.d.ts";
2
2
  export type Multiplication = (arrL: [number[], number], arrR: [number[], number], isNegative: boolean) => InputData;
@@ -1,5 +1,5 @@
1
- import type { InputData } from "../types.d.ts";
1
+ import type { Route } from "../../types.d.ts";
2
2
  import type { Multiplication } from "./types.d.ts";
3
3
  /** This function multiplies 2 numbers (as array). */
4
4
  export declare const multiplication: Multiplication;
5
- export declare const mulRoute: (input: InputData[], initValue: InputData) => InputData;
5
+ export declare const mulRoute: Route;
@@ -1,5 +1,5 @@
1
- import { DEFAULT } from "../shared/constant.js";
2
- import { a2s, s2a } from "../shared/utils.js";
1
+ import { DEFAULT } from "../../shared/constant.js";
2
+ import { a2s, s2a } from "../../shared/utils.js";
3
3
  import { subRoute } from "./utils.js";
4
4
  /** This function subtracts numbers (as string). */
5
5
  export function sub(strs) {
@@ -1,2 +1,2 @@
1
- import type { InputData } from "../types.d.ts";
1
+ import type { InputData } from "../../types.d.ts";
2
2
  export type Subtract = (L: [number[], number], R: [number[], number]) => InputData;
@@ -1,5 +1,5 @@
1
- import type { InputData } from "../types.d.ts";
1
+ import type { Route } from "../../types.d.ts";
2
2
  import type { Subtract } from "./types.d.ts";
3
3
  /** This function subtracts 2 numbers (as array). */
4
4
  export declare const subtract: Subtract;
5
- export declare const subRoute: (input: InputData[], initValue: InputData) => InputData;
5
+ export declare const subRoute: Route;
package/src/pipe/main.js CHANGED
@@ -1,9 +1,9 @@
1
- import { addRoute } from "../add/utils.js";
2
- import { divRoute } from "../div/utils.js";
3
- import { mulRoute } from "../mul/utils.js";
4
1
  import { DEFAULT } from "../shared/constant.js";
5
2
  import { a2s, s2a } from "../shared/utils.js";
6
- import { subRoute } from "../sub/utils.js";
3
+ import { subRoute } from "../mathOperations/sub/utils.js";
4
+ import { addRoute } from "../mathOperations/add/utils.js";
5
+ import { divRoute } from "../mathOperations/div/utils.js";
6
+ import { mulRoute } from "../mathOperations/mul/utils.js";
7
7
  var Pipe = /** @class */ (function () {
8
8
  function Pipe() {
9
9
  this.result = DEFAULT;
@@ -0,0 +1,2 @@
1
+ import type { Quartile } from "./types.d.ts";
2
+ export declare const quartile: Quartile;
@@ -0,0 +1,19 @@
1
+ import { pipe } from "../pipe/main.js";
2
+ var mean = function (idx, array) {
3
+ return pipe.add([array[idx], array[idx - 1]]).div(["2"]).calc();
4
+ };
5
+ export var quartile = function (array) {
6
+ if (array.length < 3) {
7
+ throw Error("To calculate quartile you need at least 3 elements");
8
+ }
9
+ var length = array.length;
10
+ var Q2Idx = length >> 1;
11
+ var Q1Idx = Q2Idx >> 1;
12
+ var Q3Idx = length - Q1Idx;
13
+ var isEvenHalf = Q2Idx % 2 !== 0;
14
+ return {
15
+ Q1: isEvenHalf ? array[Q1Idx] : mean(Q1Idx, array),
16
+ Q2: length % 2 !== 0 ? array[Q2Idx] : mean(Q2Idx, array),
17
+ Q3: isEvenHalf ? array[Q3Idx - 1] : mean(Q3Idx, array),
18
+ };
19
+ };
@@ -0,0 +1,6 @@
1
+ export type Quartile = (array: string[]) => {
2
+ Q1: string;
3
+ Q2: string;
4
+ Q3: string;
5
+ };
6
+ export type Mean = (index: number, array: string[]) => string;
package/src/types.d.ts CHANGED
@@ -4,3 +4,4 @@ export type InputData = {
4
4
  isNegative: boolean;
5
5
  isFloat: boolean;
6
6
  };
7
+ export type Route = (input: InputData[], initValue: InputData) => InputData;
@@ -1,5 +0,0 @@
1
- import type { InputData } from "../types.d.ts";
2
- import type { Addition } from "./types.d.ts";
3
- /** This function adds 2 numbers (as array). */
4
- export declare const addition: Addition;
5
- export declare const addRoute: (input: InputData[], initValue: InputData) => InputData;
@@ -1,2 +0,0 @@
1
- import type { InputData } from "../types.d.ts";
2
- export type Division = (L: [number[], number], R: [number[], number], isNegative: boolean, initLimit: number) => InputData;
@@ -1,4 +0,0 @@
1
- import type { InputData } from "../types.d.ts";
2
- import type { Division } from "./types.d.ts";
3
- export declare const division: Division;
4
- export declare const divRoute: (input: InputData[], initValue: InputData, limit: number) => InputData;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes