|
@@ -1,4 +1,7 @@
|
|
|
-const currency = (value = '0', symbol = '$', symbolPosition = 'before', thousandsSeparator = '.', decimalPlaces = 2, decimalSeparator = ',') => {
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+const currency = (value = '0', symbol = '$', symbolPosition = 'before', thousandsSeparator = '.', decimalPlaces = 2, decimalSeparator = ',', decimalZeros = false) => {
|
|
|
if (!(value instanceof String)) {
|
|
|
value = value.toString()
|
|
|
}
|
|
@@ -13,6 +16,10 @@ const currency = (value = '0', symbol = '$', symbolPosition = 'before', thousand
|
|
|
|
|
|
value = value.join(decimalSeparator)
|
|
|
|
|
|
+ if (!decimalZeros) {
|
|
|
+ value = value.replace(/([\.|,]\d)0$/, '$1')
|
|
|
+ }
|
|
|
+
|
|
|
return symbolPosition === 'before' ? `${symbol} ${value}` : `${value} ${symbol}`
|
|
|
}
|
|
|
|