Socket
Socket
Sign inDemoInstall

currency-code-symbol-map

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
148
decreased by-34.51%
Maintainers
1
Install size
9.81 kB
Created
Weekly downloads
 

Readme

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

Last updated on 02 Jun 2020

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