A comprehensive TypeScript library providing easy access to ISO currency codes and related information.
- Complete list of ISO currency codes
- Static utility methods for currency operations
- Detailed information for each currency, including:
- ISO code
- Fraction digits
- Currency name
- Symbol (where available)
- Unicode representation
- HTML and Hex codes
- Countries using the currency
npm install @sctg/currencies
import { Currencies, IsoCode, IsoCodes, isoCodes } from '@sctg/currencies';
// Get information about a specific currency
let usdInfo = isoCodes.USD;
console.log(usdInfo);
// Output:
// {
// isoCode: '840',
// fractionDigit: 2,
// symbol: '$',
// unicode: 'U+00024',
// htmlCode: '$',
// hexCode: '$',
// currencyName: 'US Dollar',
// countries: ['United States of America (The)', 'Puerto Rico', ...]
// }
usdInfo = Currencies.getCurrency('USD');
// Returns: {
// isoCode: '840',
// fractionDigit: 2,
// symbol: '$',
// unicode: 'U+00024',
// htmlCode: '$',
// hexCode: '$',
// currencyName: 'US Dollar',
// countries: ['United States of America (The)', 'Puerto Rico', ...]
// }
// Get specific currency properties
const symbol = Currencies.getCurrencySymbol('EUR'); // Returns: '€'
const name = Currencies.getCurrencyName('GBP'); // Returns: 'Pound Sterling'
const digits = Currencies.getCurrencyFractionDigit('JPY'); // Returns: 0
Method | Description | Parameters | Return Type |
---|---|---|---|
getCurrencyByCountry |
Find currency code by country name | country: string |
string | undefined |
getCurrency |
Get complete currency information | currency: IsoCode |
Currency |
getCurrencyName |
Get currency name | currency: IsoCode |
string |
getCurrencyFractionDigit |
Get number of fraction digits | currency: IsoCode |
number |
getCurrencySymbol |
Get currency symbol | currency: IsoCode |
string |
getCurrencyUnicode |
Get Unicode representation | currency: IsoCode |
string |
getCurrencyHtmlCode |
Get HTML code | currency: IsoCode |
string |
getCurrencyHexCode |
Get hexadecimal code | currency: IsoCode |
string | undefined |
getCurrencyByNumberCode |
Find currency by ISO number code | code: string |
Currency | undefined |
A type representing all available ISO currency codes (e.g., 'USD', 'EUR', 'GBP').
An interface describing the structure of currency information:
interface Currency {
isoCode: string;
fractionDigit: number;
symbol: string;
unicode: string;
htmlCode: string;
hexCode?: string;
currencyName: string;
countries: string[];
}
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.