GithubHelp home page GithubHelp logo

linusu / currency-symbol-map Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bengourley/currency-symbol-map

0.0 3.0 0.0 56 KB

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

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%

currency-symbol-map's Introduction

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 getSymbolFromCurrency = require('currency-symbol-map')

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

// =>
{
 "USD": "$",
 "GBP": "£",}

Tests

npm test

Changelog

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.

currency-symbol-map's People

Contributors

auo avatar avoyage avatar bengourley avatar bestan avatar davericher avatar garylee1 avatar k-funk avatar kunshao-msft avatar lafama avatar mattgallivan avatar matthewboman avatar michaelrhodes avatar ninagittle avatar phoenixbox avatar sarxos avatar undeadlol1 avatar yiin avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.