Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@brixtol/currency-codes

brixtol439MIT1.2.0TypeScript support: included

Mappings for 2 letter (Alpha 2) country codes to 3 letter currency code.

currencies, currency, mappings, country, 3166-1 alpha-2, ISO 4217

readme

@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.

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!

changelog

Changelog

1.2.0 - 21/10/2021

  • Updated rollup-config

1.1.1 - 09/09/2021

Allow string type to be passed as parameter value to function and replaced development rollup dependencies to use @brixtol/rollup-config

1.1.0 - 23/08/2021

Mostly development workspace adjustments. The module now exposes the mapping object on the export in addition to the matching function export.

Breakdown
  • Expose the object mapping on export, available on Currencies
  • Improved and aligned rollup build config
  • Cleaned up working directory
  • Updated readme and examples
  • Added @brixtol/eslint-config to development dependencies.
  • Added @brixtol/prettier-config to development dependencies.

1.0.1 - 22/08/2021

Minor bump to align readme information with new named export

  • Updated readme

1.0.0 - 22/08/2021

First major version, ships with a breaking change. The default export is no longer supported as this module now uses named exports.

Named export

import { getCurrency } from '@brixtol/currencies';

const currency = getCurrency('SE'); // SEK

Breakdown

  • No longer support default exports, project now uses named export approach.
  • Provided interface of currency mappings, available on ICurrencies

0.1.5 - 21/08/2021

Converted project to typescript and changed the pattern matching of how mappings are queried.

Breakdown

  • Converted project to TypeScript
  • Supported typings + JSDoc descriptions

When using a text editor that support intellisense features (like vscode) the mappings will provide the Country Name and the currency name in completions and hovers.

Currency Updates
  • Mapped LV to EUR (As of January 2014 the official currency of Latvia is EUR)

0.1.1 > 0.1.4 - 09/09/2020

  • Various adaptations for multiple registry supports

0.1.0 - 09/09/2020

  • Initial Release