Socket
Socket
Sign inDemoInstall

currency-symbol-map

Package Overview
Dependencies
0
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    currency-symbol-map

A function to lookup the currency symbol for a given currency code


Version published
Weekly downloads
222K
decreased by-22.92%
Maintainers
2
Install size
9.11 kB
Created
Weekly downloads
 

Readme

Source

currency-symbol-map

A function to lookup the currency symbol for a given currency code.

Installation

npm install currency-symbol-map

Usage

Get symbol from currency code

// ES5
const getSymbolFromCurrency = require('currency-symbol-map')

// ES6
import getSymbolFromCurrency from 'currency-symbol-map'

getSymbolFromCurrency('GBP') //=> '£'
getSymbolFromCurrency('EUR') //=> '€'
getSymbolFromCurrency('USD') //=> '$'
getSymbolFromCurrency('NOT A VALID CODE') //=> undefined

Exposed map for other processing

// ES5
const currencyToSymbolMap = require('currency-symbol-map/map')

// ES6
import currencyToSymbolMap from 'currency-symbol-map/map'

console.log(currencyToSymbolMap)
// =>
{
 "USD": "$",
 "GBP": "£",
 …
}

Tests

npm test

Changelog

5.1.0

  • Add CNH Currency mapping: #82

5.0.1

  • upgraded linter and improved code formatting (#63)

5.0.0

  • added some missing currencies (#61)
  • fixed the BTC symbol (#50)
  • fixed the KZT symbol (#52)
  • fixed the SGD symbol (#55)
  • added TypeScript typings (#53)
  • upgraded test libraries & added extra test cases (#62)

4.0.0

  • the reverse lookup feature was removed (retrieving currency given a symbol) because there is not a deterministic way to do so (i.e. the same symbol is used by multiple currencies).
  • in previous versions, an unsuccessful lookup would return the '?' character. It now returns undefined so that it is up to you how to handle the failure.

Credits

Currency symbols originally sourced from xe, but maintained and updated by contributors.

Keywords

FAQs

Last updated on 29 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc