babel-plugin-auto-numeral

0.0.1 • Public • Published

babel-plugin-auto-numeral

Actions Status Code coverage Dependency Status Dev Dependency Status NPM version NPM downloads NPM license

Why?

  1. Solving IEE754 by numeral usually takes 3 times of code, this plugin can resolve +-*/ automatically.
  2. Simulated human computing

Require

babel7

Install from npm

npm i -D babel-plugin-auto-numeral

Usage

1. add babel plugin:

{
    "plugins": [
        ["babel-plugin-auto-numeral",{"precision": 2,"numeralName": "numeral"}]
    ]
}

2. import numeral and use it

import numeral from 'numeral'; // require numeralName first
const a = 1;
console.log(numeral(a + 0.7 * 0.7)); // 1.49

options

key type description
precision number/null/undefined to pretend human calculate, this option will fix precision after every step
numeralName string transform the function named with the numeralName

Warn

The expression out of numeral will be not converted, So there is a wrong example:

import numeral from 'numeral';
// wrong
const square = (n) => n * n;
numeral(square(3.3)); // 10.889999999999999

// right
const square = (n) => numeral(n * n);
numeral(square(3.3));

// right
numeral(3.3 * 3.3)

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-auto-numeral

Weekly Downloads

3

Version

0.0.1

License

ISC

Unpacked Size

8.86 kB

Total Files

4

Last publish

Collaborators

  • paulhan