パッケージの詳細

@brixtol/currency-symbols

brixtol1.6kMIT1.1.1

Mappings from 3 letter currency codes to currency symbol

currency, mappings, country, 3166-1 alpha-2

readme

@brixtol/currency-symbols

Currency (ISO 4217) 3 letter code mappings to Currency symbol. used by the Brixtol Textiles internal API when dealing with currency conversion and presentation locales.

Size

Minified: 1.52 KB
Gzipped: 976 B

Install

pnpm

pnpm i @brixtol/currency-symbols

npm

npm install @brixtol/currency-symbols

Yarn

yarn add @brixtol/currency-symbols

Usage

You can pass in a currency code that is lowercase, uppercase or a mixture of both.

import { getCurrencySymbol } from "@brixtol/currency-symbols";

// Currency code SEK (Krona)
const sek = getCurrencySymbol("SEK"); // Kr

// Currency code EUR (Euros)
const eur = getCurrencySymbol("eur"); // €

// Currency code USD (Dollar)
const usd = getCurrencySymbol("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 { CurrencySymbols, ICurrencySymbols } from "@brixtol/currency-symbols";

// Mapping Object

CurrencySymbols.SEK; // kr
CurrencySymbols.EUR; // €
CurrencySymbols.RUB; // ₽
CurrencySymbols.USD; // $

// Interface

ICurrencySymbols.SEK; // kr
ICurrencySymbols.EUR; // €
ICurrencySymbols.RUB; // ₽
ICurrencySymbols.USD; // $

The interface is identical to the mapping.

Crypto Mappings

The module supports 4 crypto currency mappings. Only cryptos that have alt-codes are supported, please submit a PR if any are missing.

  • BTC (Bitcoin)
  • ETH (Ethereum)
  • LTL (Litecoin)
  • XBT (Bitcoin)

Related

Country code to currency code mappings:

Country code to country name (English) mappings:

Currency Symbol placements (use with currency.js)

License

Licensed under MIT


We open source!

更新履歴

Changelog

1.1.1 - 10/09/2021

Replaced development rollup dependencies to use @brixtol/rollup-config

1.1.0 - 23/08/21

This version exposes the object mappings to the export so users can use them opposed to relying on the matching function. The object mapping have been annotated with JSDoc comments which inform upon the country and name of each currency. Some currencies have been removed from the mappings which are listed below in symbol updates.

Symbol Updates

  • Removed GHC (Old Ghanaian Cedi) which is now GHS
  • Removed EEK (Estonian Kroon) which now uses EUR
  • Removed LTL (Lithuanian Litas) which was replaced in 2015 by the Euro
  • Removed ZWD (Zimbabwe Dollar) which using ISO code of ZWL (currently)

Breakdown

  • Renamed interface export to ICurrencySymbol
  • Provided JSDoc annotations for all currencies which inform upon country and currency name
  • Expose the object mapping on export, available on CurrencySymbols
  • 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.0 - 22/08/2021

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

Named export

import { getCurrencySymbol } from '@brixtol/currency-symbols';

const currency = getCurrencySymbol('SE'); // kr

Breakdown

  • No longer support default exports, project now uses named export approach.
  • Convert module to TypeScript
  • Updated development dependencies
  • Provided interface of currency mappings, available on ICurrencies

0.1.3 - 19/10/2020

  • Updated Documentation

0.1.1 > 0.1.2 - 09/09/2020

  • Various adaptations for multiple registry supports

0.1.0

09/09/2020
  • Initial Release