babel-plugin-transform-currency-operators
An experimental babel plugin for transforming currency.js operators.
Example
In
; var currency1 = ;var currency2 = currency1 + 456;var currency3 = currency2 - 456;var currency4 = currency3 * 2;var currency5 = currency4 / 4;var currency6 = currency1 + currency2; var ;var currency7 = + 5678; ifcurrency1 < currency2 ... ifcurrency1 > currency2 ... ifcurrency1 === 123 ...
Out
; var currency1 = ;var currency2 = currency1;var currency3 = currency2;var currency4 = currency3;var currency5 = currency4;var currency6 = currency1; var ;var currency7 = ; ifcurrency1value < currency2value ... ifcurrency1value > currency2value ... ifcurrency1value === 123 ...
Installation
With npm:
npm install --save-dev babel-plugin-transform-currency-operators
With yarn:
yarn install babel-plugin-transform-currency-operators --dev
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
babel --plugins transform-currency-operators
Via Node API
;
Advanced Usage
If you have a need to customize and export currency settings as a module, you can include the path to your currency (relative from the root of your project) in your .babelrc
plugin configuration to transform those imported module's operator along with any currency.js
imports:
File in your project:
path/to/custom/currency.js
; { return ;}
.babelrc
"plugins": "transform-currency-operators" customCurrency: './path/to/custom/currency'