精简数值字面量(Minify numeric literals)

通过科学计数法缩短数值字面量

Example

In

[1000, -20000]

Out

[1e3, -2e4]

Installation

npm install babel-plugin-minify-numeric-literals

Usage

.babelrc

{
  "plugins": ["minify-numeric-literals"]
}

Via CLI

babel --plugins minify-numeric-literals script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["minify-numeric-literals"]
});