nextalys-js-helpers
Advanced tools
Comparing version
@@ -74,14 +74,42 @@ "use strict"; | ||
return ''; | ||
var parsedNumber = value; | ||
if (typeof value === 'string') { | ||
parsedNumber = parseFloat(value); | ||
} | ||
var strValue = value.toString(); | ||
if (strValue.indexOf('.') !== -1) { | ||
var arr = strValue.split('.'); | ||
var rightPart = arr[1]; | ||
if (decimals != null) { | ||
rightPart = this.padRight(arr[1], decimals, '0'); | ||
} | ||
rightPart = rightPart.replace(/ /g, ""); | ||
if (decimals != null && rightPart.length > decimals) { | ||
parsedNumber = MainHelpers.round(parsedNumber, decimals); | ||
} | ||
} | ||
strValue = parsedNumber.toString(); | ||
strValue = strValue.replace(/ /g, ""); | ||
strValue = strValue.replace(/\B(?=(\d{3})+(?!\d))/g, " "); | ||
if (decimals && (strValue.indexOf('.') !== -1 || forceDecimals)) { | ||
if (strValue.indexOf('.') !== -1 || forceDecimals) { | ||
var leftPart = void 0; | ||
var rightPart = void 0; | ||
if (strValue.indexOf('.') !== -1) { | ||
var arr = strValue.split('.'); | ||
strValue = arr[0] + '.' + this.padRight(arr[1], decimals, '0'); | ||
leftPart = arr[0]; | ||
rightPart = arr[1]; | ||
if (decimals != null) { | ||
rightPart = this.padRight(rightPart, decimals, '0'); | ||
} | ||
} | ||
else { | ||
leftPart = strValue; | ||
//force decimals | ||
strValue = strValue + '.' + this.padRight('', decimals, '0'); | ||
if (decimals == null) { | ||
decimals = 2; | ||
} | ||
rightPart = this.padRight('', decimals, '0'); | ||
} | ||
rightPart = rightPart.replace(/ /g, ""); | ||
strValue = leftPart + '.' + rightPart; | ||
} | ||
@@ -88,0 +116,0 @@ return strValue; |
{ | ||
"name": "nextalys-js-helpers", | ||
"version": "0.2.110", | ||
"version": "0.2.111", | ||
"description": "Nextalys Javascript Helpers", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1204393
0.16%18618
0.15%