@darkpos/utils 1.0.8 → 1.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/lib/math.js +14 -4
- package/package.json +2 -2
package/lib/math.js
CHANGED
|
@@ -15,7 +15,7 @@ const add = (...args) => {
|
|
|
15
15
|
Decimal(0)
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
return Decimal(sum
|
|
18
|
+
return Decimal(sum).toNumber();
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
//
|
|
@@ -30,7 +30,7 @@ const sub = (...args) => {
|
|
|
30
30
|
Decimal(first)
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
return Decimal(sum
|
|
33
|
+
return Decimal(sum).toNumber();
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const mul = (...args) => {
|
|
@@ -42,7 +42,7 @@ const mul = (...args) => {
|
|
|
42
42
|
Decimal(1)
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
return Decimal(sum
|
|
45
|
+
return Decimal(sum).toNumber();
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const div = (...args) => {
|
|
@@ -56,7 +56,7 @@ const div = (...args) => {
|
|
|
56
56
|
Decimal(first)
|
|
57
57
|
);
|
|
58
58
|
|
|
59
|
-
return Decimal(sum
|
|
59
|
+
return Decimal(sum).toNumber();
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
//
|
|
@@ -83,6 +83,13 @@ const abs = x => Decimal(x).abs().toNumber();
|
|
|
83
83
|
//
|
|
84
84
|
const toFixed = x => Decimal(x).toFixed(2, 1);
|
|
85
85
|
|
|
86
|
+
//
|
|
87
|
+
const toDecimalPlaces = x => Decimal(x).toDecimalPlaces(2).toNumber();
|
|
88
|
+
|
|
89
|
+
const max = (...args) => Decimal.max(...args).toNumber();
|
|
90
|
+
|
|
91
|
+
const min = (...args) => Decimal.min(...args).toNumber();
|
|
92
|
+
|
|
86
93
|
module.exports = {
|
|
87
94
|
mul,
|
|
88
95
|
div,
|
|
@@ -96,4 +103,7 @@ module.exports = {
|
|
|
96
103
|
eq,
|
|
97
104
|
isZero,
|
|
98
105
|
toFixed,
|
|
106
|
+
toDecimalPlaces,
|
|
107
|
+
max,
|
|
108
|
+
min,
|
|
99
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "General purpose utilities",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"homepage": "https://gitlab.com/darkpos/packages/dark#readme",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"eslint-plugin-prettier": "^4.0.0",
|
|
40
40
|
"prettier": "^2.7.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "6648705882ec8351463ba823c213cf7c198129ce"
|
|
43
43
|
}
|