Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-minify-numeric-literals

Package Overview
Dependencies
Maintainers
5
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-minify-numeric-literals - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0-alpha.a7421897

25

lib/index.js
"use strict";
module.exports = function (_ref) {
var t = _ref.types;
module.exports = function () {
return {

@@ -12,12 +10,17 @@ name: "minify-numeric-literals",

var exponential = path.node.value.toExponential().replace(/\+/g, "").replace(/e0/, "");
var normal = path.node.value.toString().replace(/^0\./, ".");
var exponential = path.node.value.toExponential().replace(/\+/g, "");
if (path.node.extra.raw.length > exponential.length) {
var literal = t.numericLiteral(path.node.value);
literal.extra = {
raw: exponential,
rawValue: path.node.value
};
path.replaceWith(literal);
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;
exponential = (exponential.substr(0, exponential.lastIndexOf("e") + 1) + (lastChar - subLength)).replace(".", "").replace(/e0/, "");
}
var replacement = normal.length > exponential.length ? exponential : normal;
if (path.node.extra.raw.length > replacement.length) {
path.node.extra.raw = replacement;
}
}

@@ -24,0 +27,0 @@ }

{
"name": "babel-plugin-minify-numeric-literals",
"version": "0.2.0",
"version": "0.3.0-alpha.a7421897",
"description": "Shortens numeric literals using scientific notation",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc