Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

currency-code-symbol-map

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-code-symbol-map

Utility functions to map currency code to symbol and vice versa

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Currency Code Symbol Map

Utility functions for currency symbols and codes.


Install

$ npm i currency-code-symbol-map

or

$ yarn install currency-code-symbol-map

Usage

It contains four utility functions along with a mapping of currency codes and symbols.

1. Map Codes from Symbol

A Symbol may belong to multiple codes. For example symbol for USD (US Dollar) and CAD (Canadian Dollar) is same, which is $. So this method returns an array of codes.

    import { getCodesFromSymbol } from "currency-code-symbol-map";

    console.log(getCodesFromSymbol('₹')) 
    // INR

If

2. Map currency Symbol from Code

import { getSymbolFromCode } from "currency-code-symbol-map";

console.log(getSymbolFromCode('USD')) 
// $

console.log(getCodeFromSymbol('SOME INVALID SYMBOL'));
// undefined

3. Validate currency currency symbol

import { isValidCurrencySymbol } from "currency-code-symbol-map";

console.log(isValidCurrencySymbol('$')) 
// true

console.log(isValidCurrencySymbol('%'));
// false

4. Validate currency code

import { isValidCurrencyCode } from "currency-code-symbol-map";

console.log(isValidCurrencyCode('USD')) 
// true

console.log(isValidCurrencyCode('XYZ'));
// false

FAQs

Package last updated on 02 Jun 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc