gl-w-frontend
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -17,3 +17,3 @@ import { TCurrencyNames, TCurrencySymbolTypes, TDecimalSeparators } from './core-services-string-interface'; | ||
currencyNameToSymbol(currency: TCurrencyNames): string; | ||
decimalNumberToString(num: number, decimalOutput?: TDecimalSeparators): string; | ||
decimalNumberToString(num: number, decimalOutput?: TDecimalSeparators, places?: number): string; | ||
formatNumber(num: number, decimal?: TDecimalSeparators): string; | ||
@@ -20,0 +20,0 @@ numberToString(number: number): string; |
@@ -0,1 +1,2 @@ | ||
import Decimal from 'decimal.js'; | ||
import { UrlDecode } from '../url/core-services-url.service'; | ||
@@ -110,7 +111,9 @@ class Clean { | ||
} | ||
decimalNumberToString(num, decimalOutput = '.') { | ||
const value = Math.round((num + Number.EPSILON) * 100.0) / 100.0; | ||
return value | ||
.toString() | ||
.replace('.', decimalOutput); | ||
decimalNumberToString(num, decimalOutput = '.', places = 2) { | ||
const value = new Decimal(num); | ||
const stringValue = value.toDecimalPlaces(places).toFixed(places); | ||
const separator = decimalOutput === ',' ? '$1.' : '$1,'; | ||
return stringValue | ||
.replace('.', decimalOutput) | ||
.replace(/(\d)(?=(\d{3})+(?!\d))/g, separator); | ||
} | ||
@@ -117,0 +120,0 @@ formatNumber(num, decimal = '.') { |
{ | ||
"name": "gl-w-frontend", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Common code for using among web front-end development such as ES6+ and TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bundle.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
253389
3904