@brixtol/currency-codes
Country codes (3166-1 alpha-2) to Currency (ISO 4217) code mappings used by the Brixtol Textiles internal API when dealing with pricing and currency conversions. Supports all 249 countries to currency maps.
Minified: 2.23 KB
Gzipped: 1.08 KB
Install
pnpm i @brixtol/currency-codes
Because pnpm is dope and does dope shit.
npm install @brixtol/currency-codes
yarn add @brixtol/currency-codes
Usage
You can pass in a country code that is lowercase, uppercase or a mixture of both.
import { getCurrency } from "@brixtol/currency-codes";
// Country code SE (Sweden)
const sek = getCurrency("SE"); // SEK
// Country code NL (Netherlands)
const eur = getCurrency("nl"); // EUR
// Country code US (United States)
const eur = getCurrency("uS"); // USD
// ....
The module also exposes the raw mappings and interface on the export. The mappings object is provided read only using Object.freeze. The raw mappings are annotated with JSDoc comments so when using an editor that supports intellisense (ie: vscode) you will receive the country and currency name in completions and hovers.
import { Currencies, ICurrencies } from "@brixtol/currency-codes";
// Mapping Object
Currencies.SE; // SEK
Currencies.NL; // EUR
Currencies.RU; // RUB
// Interface
ICurrencies.SE; // SEK
ICurrencies.NL; // EUR
ICurrencies.RU; // RUB
The interface is identical to the mapping.
Related
Currency code to currency symbol mappings:
Country code to country name mappings:
Currency code to currency.js symbol placement mappings:
License
Licensed under MIT
We ♡ open source!