@easymoney/currencies
v1.0.2
Published
Best way to do money in js
Downloads
2,907
Maintainers
Readme
@easymoney/currencies
Install
npm install @easymoney/currencies
or
yarn add @easymoney/currencies
or
CDN
Usage
import { createCurrencyList } from '@easymoney/currencies';
const currency = { minorUnit: 2, code: 'XBT' };
const currency1 = { minorUnit: 5, code: 'DXBT' };
const currencyArr = [currency, currency1];
const list = createCurrencyList(currencyArr);
const result = list.getCurrencies();
// => { XBT: {minorUnit: 2, code: "XBT"},
// DXBT: {minorUnit: 5, code: "DXBT"} }
const resultLength = Object.keys(result).length === currencyArr.length ? true : false;
// => true
import { createCurrencyList, createAgregatedCurrencyList } from '@easymoney/currencies';
const currency = { minorUnit: 2, code: 'XBT' };
const currency1 = { minorUnit: 5, code: 'DXBT' };
const currencyArr = [currency, currency1];
const list = createCurrencyList(currencyArr);
const agregatedList = createAgregatedCurrencyList([list]);
const result = agregatedList.subUnitFor("XBT");
// => 2