Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
babel-plugin-minify-numeric-literals
Advanced tools
Shortens numeric literals using scientific notation
The babel-plugin-minify-numeric-literals package is a Babel plugin that minifies numeric literals in your JavaScript code. It converts numeric literals to their shortest representation, which can help reduce the size of the code and potentially improve performance.
Minify Integer Literals
This feature converts large integer literals into their exponential form to save space. For example, the integer 1000 is converted to 1e3.
const a = 1000; // becomes const a = 1e3;
Minify Floating-Point Literals
This feature converts small floating-point literals into their exponential form. For example, the floating-point number 0.000001 is converted to 1e-6.
const b = 0.000001; // becomes const b = 1e-6;
Minify Hexadecimal Literals
This feature converts hexadecimal literals to their decimal form if it results in a shorter representation. For example, the hexadecimal number 0xFF is converted to 255.
const c = 0xFF; // becomes const c = 255;
This package minifies boolean literals in your code. It converts true and false to !0 and !1 respectively, which can save space. Unlike babel-plugin-minify-numeric-literals, it focuses on boolean values rather than numeric literals.
This package performs constant folding, which is the process of simplifying constant expressions at compile time. It can optimize arithmetic expressions, boolean expressions, and more. While it can handle numeric literals, its scope is broader than just minifying numeric literals.
This package simplifies expressions and statements in your code. It can remove unnecessary code, inline variables, and more. It includes numeric literal simplification as part of its broader optimization strategies.
Shortening of numeric literals via scientific notation
In
[1000, -20000]
Out
[1e3, -2e4]
npm install babel-plugin-minify-numeric-literals --save-dev
.babelrc
(Recommended).babelrc
{
"plugins": ["minify-numeric-literals"]
}
babel --plugins minify-numeric-literals script.js
require("@babel/core").transform("code", {
plugins: ["minify-numeric-literals"]
});
FAQs
Shortens numeric literals using scientific notation
The npm package babel-plugin-minify-numeric-literals receives a total of 157,437 weekly downloads. As such, babel-plugin-minify-numeric-literals popularity was classified as popular.
We found that babel-plugin-minify-numeric-literals demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.