Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coingaming/node-money
https://github.com/coingaming/node-money
Last synced: about 15 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/coingaming/node-money
- Owner: coingaming
- Created: 2018-01-11T16:29:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-04T13:34:59.000Z (about 2 months ago)
- Last Synced: 2024-10-14T08:55:20.928Z (about 1 month ago)
- Language: TypeScript
- Size: 2.07 MB
- Stars: 1
- Watchers: 39
- Forks: 2
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
## Usage
```bash
npm install --save "@heathmont/money"
``````typescript
import { toInteger, fromInteger, convertUnit } from "@heathmont/money";
```### toInteger(amount, currency, [unit])
```typescript
toInteger(111111.222333443, 'BTC')
11111122233344toInteger(111111222.333443, 'BTC', 'mBTC')
11111122233344toInteger(111111.223332, 'EUR')
11111122333toInteger(11111122.3332, 'EUR', 'cent')
11111122333
```### fromInteger(amount, currency, [unit])
```typescript
fromInteger(11111122233344, 'BTC')
111111.22233344fromInteger(11111122233344, 'BTC', 'uBTC')
111111222333.44fromInteger(11111122333, 'EUR')
111111.22333fromInteger(11111122333, 'EUR', 'cent')
11111122.333
```### convertUnit(amount, currency, fromUnit, toUnit)
```typescript
convertUnit(111111222.333443, 'BTC', 'mBTC', 'uBTC')
111111222333.44convertUnit(111111.223332, 'EUR', 'EUR', 'cent')
11111122.333
```