@cashub/utils 0.6.2 → 0.7.0
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/format/formatPrice.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Convert the price to include specified decimal places
|
|
9
|
+
*/
|
|
10
|
+
const formatPrice = price => {
|
|
11
|
+
let result = price;
|
|
12
|
+
if (typeof result !== 'number') {
|
|
13
|
+
result = Number(result);
|
|
14
|
+
}
|
|
15
|
+
return result.toFixed(2);
|
|
16
|
+
};
|
|
17
|
+
var _default = exports.default = formatPrice;
|