![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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
.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 206,687 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.