safe-math-ops 0.0.7 → 0.0.9
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/dist/index.d.ts +5 -3
- package/dist/index.js +12 -5
- package/dist/libs/format.d.ts +5 -0
- package/dist/libs/subtract.d.ts +1 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,16 +4,18 @@ import divide from "./libs/divide";
|
|
|
4
4
|
import getPow from "./libs/getPow";
|
|
5
5
|
import multiply from "./libs/multiply";
|
|
6
6
|
import replaceByInt from "./libs/replaceByInt";
|
|
7
|
-
import
|
|
8
|
-
|
|
7
|
+
import subtract from "./libs/subtract";
|
|
8
|
+
import format from "./libs/format";
|
|
9
|
+
export { add, subtract, multiply, divide, calcHighestDecimalPoint, calcDecimals, getPow, replaceByInt, format, };
|
|
9
10
|
declare const _default: {
|
|
10
11
|
add: typeof add;
|
|
11
|
-
|
|
12
|
+
subtract: typeof subtract;
|
|
12
13
|
multiply: typeof multiply;
|
|
13
14
|
divide: typeof divide;
|
|
14
15
|
calcHighestDecimalPoint: typeof calcHighestDecimalPoint;
|
|
15
16
|
calcDecimals: typeof calcDecimals;
|
|
16
17
|
getPow: typeof getPow;
|
|
17
18
|
replaceByInt: typeof replaceByInt;
|
|
19
|
+
format: typeof format;
|
|
18
20
|
};
|
|
19
21
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -56,8 +56,8 @@ function replaceByInt(numbers, multiplier) {
|
|
|
56
56
|
return numbers;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// src/libs/
|
|
60
|
-
function
|
|
59
|
+
// src/libs/subtract.ts
|
|
60
|
+
function subtract(numbers) {
|
|
61
61
|
const highDecimalPoint = calcHighestDecimalPoint(numbers);
|
|
62
62
|
const multiplier = getPow(highDecimalPoint);
|
|
63
63
|
return numbers.reduce((a, b) => {
|
|
@@ -65,22 +65,29 @@ function substract(numbers) {
|
|
|
65
65
|
}) / multiplier;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// src/libs/format.ts
|
|
69
|
+
function format(number, precision = 15) {
|
|
70
|
+
return Math.round(number * 10 ** precision) / 10 ** precision;
|
|
71
|
+
}
|
|
72
|
+
|
|
68
73
|
// src/index.ts
|
|
69
74
|
var src_default = {
|
|
70
75
|
add,
|
|
71
|
-
|
|
76
|
+
subtract,
|
|
72
77
|
multiply,
|
|
73
78
|
divide,
|
|
74
79
|
calcHighestDecimalPoint,
|
|
75
80
|
calcDecimals,
|
|
76
81
|
getPow,
|
|
77
|
-
replaceByInt
|
|
82
|
+
replaceByInt,
|
|
83
|
+
format
|
|
78
84
|
};
|
|
79
85
|
export {
|
|
80
|
-
|
|
86
|
+
subtract,
|
|
81
87
|
replaceByInt,
|
|
82
88
|
multiply,
|
|
83
89
|
getPow,
|
|
90
|
+
format,
|
|
84
91
|
divide,
|
|
85
92
|
src_default as default,
|
|
86
93
|
calcHighestDecimalPoint,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function subtract(numbers: number[]): number;
|
package/package.json
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
"name": "safe-math-ops",
|
|
3
3
|
"module": "src/index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.9",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@types/bun": "latest",
|
|
8
|
-
"rimraf": "^6.1.3"
|
|
8
|
+
"rimraf": "^6.1.3",
|
|
9
|
+
"tinybench": "^6.1.3"
|
|
9
10
|
},
|
|
10
11
|
"peerDependencies": {
|
|
11
12
|
"typescript": "^5"
|