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

currency-library

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-library

Easily get data about different currencies

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
163
increased by22.56%
Maintainers
1
Weekly downloads
 
Created
Source

currency-library

build coverage version license size

Easily get data about different currencies in Javascript

Usage

getAll

getByIsoCode

getByNumericCode

getBySymbol

getAll

Parameters

None

Return value

Returns object with ISO currency code as a key

const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';

console.log(currencyLibrary.getAll());
/** =>
 {
  //...
  USD: {
    isoCode: 'USD',
    numericCode: '840',
    minorUnits: 2,
    name: 'United States dollar',
    symbol: '$'
  },
  UAH: {
    isoCode: 'UAH',
    numericCode: '980',
    minorUnits: 2,
    name: 'Ukrainian hryvnia',
    symbol: '₴'
  },
  // ...
}
 **/

getByIsoCode

Parameters

Expects ISO code string as only parameter

Return value

Returns currency object or undefined if currency not found

const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';

console.log(currencyLibrary.getByIsoCode('UAH'));
/** =>
 {
  isoCode: 'UAH',
  numericCode: '980',
  minorUnits: 2,
  name: 'Ukrainian hryvnia',
  symbol: '₴'
}
 **/
console.log(currencyLibrary.getByIsoCode('WRONG CODE'));
// => undefined

getByNumericCode

Parameters

Expects numeric currency code as only parameter

Return value

Returns currency object or undefined if currency not found

const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';

console.log(currencyLibrary.getByNumericCode(980));
/** =>
 {
  isoCode: 'UAH',
  numericCode: '980',
  minorUnits: 2,
  name: 'Ukrainian hryvnia',
  symbol: '₴'
}
 **/
console.log(currencyLibrary.getByNumericCode(-1));
// => undefined

getBySymbol

Parameters

Expects symbol parameter as only parameter

Return value

Returns currency object or undefined if currency not found

const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';

console.log(currencyLibrary.getBySymbol('₴'));
/** =>
 {
  isoCode: 'UAH',
  numericCode: '980',
  minorUnits: 2,
  name: 'Ukrainian hryvnia',
  symbol: '₴'
}
 **/
console.log(currencyLibrary.getBySymbol('~'));
// => undefined

Development

Run tests:

npm test -- --coverage

Keywords

FAQs

Package last updated on 19 Jul 2022

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