ISO 4217 Currencies
Complete list of ISO 4217 currencies supported by @genkin/currencies.
Major Currencies
The most commonly used currencies worldwide:
| Code | Name | Symbol | Precision |
|---|---|---|---|
| USD | US Dollar | $ | 2 |
| EUR | Euro | € | 2 |
| GBP | British Pound Sterling | £ | 2 |
| JPY | Japanese Yen | ¥ | 0 |
| CNY | Chinese Yuan | ¥ | 2 |
| CHF | Swiss Franc | CHF | 2 |
| CAD | Canadian Dollar | C$ | 2 |
| AUD | Australian Dollar | A$ | 2 |
| NZD | New Zealand Dollar | NZ$ | 2 |
| SEK | Swedish Krona | kr | 2 |
| NOK | Norwegian Krone | kr | 2 |
| DKK | Danish Krone | kr | 2 |
Usage
Import and use any currency:
import { genkin } from '@genkin/core';
import { USD, EUR, GBP, JPY } from '@genkin/currencies';
const usd = genkin(100, { currency: USD });
const eur = genkin(85, { currency: EUR });
const gbp = genkin(75, { currency: GBP });
const jpy = genkin(15000, { currency: JPY });
Zero-Precision Currencies
Some currencies don't have fractional units:
| Code | Name | Symbol | Precision |
|---|---|---|---|
| JPY | Japanese Yen | ¥ | 0 |
| KRW | South Korean Won | ₩ | 0 |
| VND | Vietnamese Dong | ₫ | 0 |
| CLP | Chilean Peso | $ | 0 |
| ISK | Icelandic Króna | kr | 0 |
| TWD | New Taiwan Dollar | NT$ | 0 |
import { genkin } from '@genkin/core';
import { JPY, KRW } from '@genkin/currencies';
// These amounts are always whole numbers
const yen = genkin(1000, { currency: JPY });
const won = genkin(50000, { currency: KRW });
Three-Decimal Currencies
Some currencies use 3 decimal places:
| Code | Name | Symbol | Precision |
|---|---|---|---|
| BHD | Bahraini Dinar | BD | 3 |
| JOD | Jordanian Dinar | JD | 3 |
| KWD | Kuwaiti Dinar | KD | 3 |
| OMR | Omani Rial | OMR | 3 |
| TND | Tunisian Dinar | DT | 3 |
import { genkin } from '@genkin/core';
import { KWD } from '@genkin/currencies';
const dinar = genkin(10.500, { currency: KWD });
console.log(dinar.precision); // 3
All Supported Currencies
@genkin/currencies includes 180+ ISO 4217 currencies. Here are some examples by region:
Americas
- USD (US Dollar), CAD (Canadian Dollar), MXN (Mexican Peso)
- BRL (Brazilian Real), ARS (Argentine Peso), CLP (Chilean Peso)
- COP (Colombian Peso), PEN (Peruvian Sol), VES (Venezuelan Bolívar)
Europe
- EUR (Euro), GBP (British Pound), CHF (Swiss Franc)
- SEK (Swedish Krona), NOK (Norwegian Krone), DKK (Danish Krone)
- PLN (Polish Złoty), CZK (Czech Koruna), HUF (Hungarian Forint)
- RON (Romanian Leu), BGN (Bulgarian Lev), HRK (Croatian Kuna)
Asia-Pacific
- JPY (Japanese Yen), CNY (Chinese Yuan), KRW (South Korean Won)
- INR (Indian Rupee), IDR (Indonesian Rupiah), THB (Thai Baht)
- MYR (Malaysian Ringgit), SGD (Singapore Dollar), PHP (Philippine Peso)
- VND (Vietnamese Dong), AUD (Australian Dollar), NZD (New Zealand Dollar)
Middle East & Africa
- AED (UAE Dirham), SAR (Saudi Riyal), QAR (Qatari Riyal)
- ILS (Israeli Shekel), TRY (Turkish Lira), EGP (Egyptian Pound)
- ZAR (South African Rand), NGN (Nigerian Naira), KES (Kenyan Shilling)
Importing Currencies
Individual Imports
import { USD, EUR, GBP } from '@genkin/currencies';
Bulk Imports
import * as currencies from '@genkin/currencies';
const usd = currencies.USD;
const eur = currencies.EUR;
Configuration Objects
import { USD_CONFIG, EUR_CONFIG } from '@genkin/currencies';
console.log(USD_CONFIG);
// {
// code: 'USD',
// numeric: 840,
// precision: 2,
// symbol: '$',
// name: 'US Dollar',
// base: 10
// }
Factory Functions
import { createUSD, createEUR } from '@genkin/currencies';
const usd = createUSD();
const eur = createEUR();
Currency Properties
Each currency object includes:
import { USD } from '@genkin/currencies';
console.log(USD.code); // "USD"
console.log(USD.numeric); // 840 (ISO 4217 numeric code)
console.log(USD.precision); // 2
console.log(USD.symbol); // "$"
console.log(USD.name); // "US Dollar"
console.log(USD.base); // 10
Formatting and Parsing
All currency objects support formatting and parsing:
import { USD, EUR, JPY } from '@genkin/currencies';
// Formatting
console.log(USD.format(1234.56)); // "$1,234.56"
console.log(EUR.format(1234.56)); // "€1,234.56"
console.log(JPY.format(1234)); // "¥1,234"
// Parsing
console.log(USD.parse('$1,234.56')); // 1234.56
console.log(EUR.parse('€1,234.56')); // 1234.56
console.log(JPY.parse('¥1,234')); // 1234
Type-Safe Currency Codes
Use typed currency codes for better type safety:
import { USD_CODE, EUR_CODE, type USDCode, type EURCode } from '@genkin/currencies';
function processUSD(code: USDCode) {
console.log(`Processing ${code}`);
}
processUSD(USD_CODE); // OK
processUSD('USD'); // OK
// processUSD('EUR'); // Type error!
Custom Currencies
Need a currency not in ISO 4217? Create a custom one:
import { createCurrency } from '@genkin/core';
const BTC = createCurrency({
code: 'BTC',
numeric: 0,
precision: 8,
symbol: '₿',
name: 'Bitcoin',
base: 10
});
Next Steps
- Learn about currency operations
- See creating amounts with currencies
- Explore currency conversion