@darkpos/utils 1.0.8 → 1.0.10

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.
@@ -172,6 +172,7 @@ const formatAmountWithCurrency = (amount, currency, locale) =>
172
172
  ? new Intl.NumberFormat(locale, {
173
173
  style: 'currency',
174
174
  currency,
175
+ signDisplay: 'negative'
175
176
  }).format(Number(amount))
176
177
  : '';
177
178
 
package/lib/math.js CHANGED
@@ -15,7 +15,7 @@ const add = (...args) => {
15
15
  Decimal(0)
16
16
  );
17
17
 
18
- return Decimal(sum.toFixed(2, 1)).toNumber();
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.toFixed(2, 1)).toNumber();
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.toFixed(2, 1)).toNumber();
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.toFixed(2, 1)).toNumber();
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.8",
3
+ "version": "1.0.10",
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": "1c4565d3c097c833093794654d8adc18e37767b9"
42
+ "gitHead": "e34041588c206612b5c2dff2e27aa34ac838137e"
43
43
  }