Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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 403,447 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.