babel-plugin-minify-numeric-literals
Advanced tools
Comparing version 0.5.0-alpha.55276695 to 0.5.0-alpha.34c3efe9
@@ -9,13 +9,13 @@ "use strict"; | ||
if (!path.node.extra) return; | ||
var normal = path.node.value.toString().replace(/^0\./, "."); | ||
var exponential = path.node.value.toExponential().replace(/\+/g, ""); | ||
const normal = path.node.value.toString().replace(/^0\./, "."); | ||
let exponential = path.node.value.toExponential().replace(/\+/g, ""); | ||
if (exponential.indexOf(".") >= 0 && exponential.indexOf("e") >= 0) { | ||
var lastChar = exponential.substr(exponential.lastIndexOf("e") + 1); | ||
var dotIndex = exponential.lastIndexOf(".") + 1; | ||
var subLength = exponential.substr(dotIndex, exponential.lastIndexOf("e") - dotIndex).length; | ||
const lastChar = exponential.substr(exponential.lastIndexOf("e") + 1); | ||
const dotIndex = exponential.lastIndexOf(".") + 1; | ||
const subLength = exponential.substr(dotIndex, exponential.lastIndexOf("e") - dotIndex).length; | ||
exponential = (exponential.substr(0, exponential.lastIndexOf("e") + 1) + (lastChar - subLength)).replace(".", "").replace(/e0/, ""); | ||
} | ||
var replacement = normal.length > exponential.length ? exponential : normal; | ||
const replacement = normal.length > exponential.length ? exponential : normal; | ||
@@ -22,0 +22,0 @@ if (path.node.extra.raw.length > replacement.length) { |
{ | ||
"name": "babel-plugin-minify-numeric-literals", | ||
"version": "0.5.0-alpha.55276695", | ||
"version": "0.5.0-alpha.34c3efe9", | ||
"description": "Shortens numeric literals using scientific notation", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
2121
185994