@brixtol/currency-codes
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@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

pnpm i @brixtol/currency-codes

Because pnpm is dope and does dope shit.

npm

npm install @brixtol/currency-codes

Yarn

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!

Package Sidebar

Install

npm i @brixtol/currency-codes

Weekly Downloads

62

Version

1.2.0

License

MIT

Unpacked Size

26.2 kB

Total Files

9

Last publish

Collaborators

  • sissel