biggystring
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -28,8 +28,16 @@ /** | ||
// Remove trailing zeros and decimal | ||
// Remove starting and trailing zeros and decimal | ||
function trimEnd(val) { | ||
// if (val === '0') { | ||
// return val | ||
// } | ||
// Remove starting zeros if there are any | ||
var out = val.replace(/^0+/, ''); | ||
out = out.replace(/^\.+/, '0.'); | ||
if (out.includes('.')) { | ||
// Remove trailing zeros | ||
out = out.replace(/0+$/, ''); | ||
// Remove trailing "." if there is one | ||
out = out.replace(/\.+$/, ''); | ||
@@ -40,2 +48,5 @@ if (out === '') { | ||
} | ||
if (out === '') { | ||
out = '0'; | ||
} | ||
return out; | ||
@@ -405,3 +416,7 @@ } | ||
if (decimalPos === -1) { | ||
return x + '.' + addZeros('', minPrecision); | ||
var out = x + '.' + addZeros('', minPrecision); | ||
// Remove trailing "." if there is one | ||
out = out.replace(/\.+$/, ''); | ||
return out; | ||
} else { | ||
@@ -408,0 +423,0 @@ var numDecimals = x.length - decimalPos - 1; |
@@ -32,8 +32,16 @@ 'use strict'; | ||
// Remove trailing zeros and decimal | ||
// Remove starting and trailing zeros and decimal | ||
function trimEnd(val) { | ||
// if (val === '0') { | ||
// return val | ||
// } | ||
// Remove starting zeros if there are any | ||
var out = val.replace(/^0+/, ''); | ||
out = out.replace(/^\.+/, '0.'); | ||
if (out.includes('.')) { | ||
// Remove trailing zeros | ||
out = out.replace(/0+$/, ''); | ||
// Remove trailing "." if there is one | ||
out = out.replace(/\.+$/, ''); | ||
@@ -44,2 +52,5 @@ if (out === '') { | ||
} | ||
if (out === '') { | ||
out = '0'; | ||
} | ||
return out; | ||
@@ -409,3 +420,7 @@ } | ||
if (decimalPos === -1) { | ||
return x + '.' + addZeros('', minPrecision); | ||
var out = x + '.' + addZeros('', minPrecision); | ||
// Remove trailing "." if there is one | ||
out = out.replace(/\.+$/, ''); | ||
return out; | ||
} else { | ||
@@ -412,0 +427,0 @@ var numDecimals = x.length - decimalPos - 1; |
{ | ||
"name": "biggystring", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"description": "Full floating point big number library using regular Javascript string", | ||
@@ -25,12 +25,10 @@ "keywords": [ | ||
"scripts": { | ||
"build": "npm run lint && npm run prepare && npm run build:flow", | ||
"build:flow": "npm run flow && flow-copy-source -v -i '**/test/**' src lib", | ||
"precommit": "npm test", | ||
"cover": "nyc --reporter=lcov --reporter=text --reporter=html --extension .js npm test", | ||
"build": "rollup -c && flow-copy-source -v -i '**/test/**' src lib", | ||
"flow": "flow", | ||
"lint": "standard '*.js' 'src/**/*.js'", | ||
"lint": "standard '*.js' 'src/**/*.js' && npm run flow", | ||
"lint --fix": "standard '*.js' 'src/**/*.js' --fix", | ||
"prepare": "npm run rollup", | ||
"rollup": "rollup -c", | ||
"test": "npm run build && mocha" | ||
"test": "npm run lint && mocha", | ||
"precommit": "npm run build && npm test", | ||
"cover": "nyc --reporter=lcov --reporter=text --reporter=html --extension .js npm test", | ||
"prepare": "npm run build" | ||
}, | ||
@@ -37,0 +35,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
83506
811