https://github.com/gtkatakura/decimal.js.macro
A babel-macro to transpile arithmetic expressions to `decimal.js`
https://github.com/gtkatakura/decimal.js.macro
babel-macro decimal macros
Last synced: 5 months ago
JSON representation
A babel-macro to transpile arithmetic expressions to `decimal.js`
- Host: GitHub
- URL: https://github.com/gtkatakura/decimal.js.macro
- Owner: gtkatakura
- License: mit
- Created: 2018-07-28T02:54:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T02:07:58.000Z (about 3 years ago)
- Last Synced: 2023-08-24T01:32:33.332Z (almost 3 years ago)
- Topics: babel-macro, decimal, macros
- Language: JavaScript
- Size: 1.09 MB
- Stars: 20
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# decimal.js.macro
[](https://circleci.com/gh/gtkatakura/decimal.js.macro)
[](https://badge.fury.io/js/decimal.js.macro)
[](https://github.com/gtkatakura/decimal.js.macro/blob/master/LICENSE.md)
[](https://github.com/semantic-release/semantic-release)
## Usage
```js
import decimal from 'decimal.js.macro'
const a = decimal(1)
const b = decimal(a - 3 * 4 / 5)
const c = decimal(a - 3 + 4 - 5)
const d = decimal(1 ** 2 ** 3)
↓ ↓ ↓ ↓ ↓ ↓
import { Decimal as _Decimal } from 'decimal.js';
const a = _Decimal('1');
const b = _Decimal(a).sub(_Decimal(_Decimal('3').mul('4')).div('5'));
const c = _Decimal(_Decimal(_Decimal(a).sub('3')).add('4')).sub('5');
const d = _Decimal('1').pow(_Decimal('2').pow('3'));
```
## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
| [
gtkatakura](https://github.com/gtkatakura)
[💻](https://github.com/gtkatakura/decimal.js.macro/commits?author=gtkatakura "Code") [🤔](#ideas-gtkatakura "Ideas, Planning, & Feedback") [⚠️](https://github.com/gtkatakura/decimal.js.macro/commits?author=gtkatakura "Tests") |
| :---: |
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!