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

@divvit/currency-converter

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@divvit/currency-converter

Convert a value from one currency to another according to exchange rate of a certain day.

  • 2.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Currency Converter

A small library to convert currencies according to the EZB exchange rates.

Installation

npm install @divvit/currency-converter --save

Usage

  var converter = require('@divvit/currency-converter')();
  // if you want to change the storage path, call the script like that:
  // var converter = require('@divvit/currency-converter')({ storageDir: '/some/other/path' });
  // the default path is process.env.TMPDIR

  var moment = require('moment');

  var eurValue = 10;
  var conversionDate = moment('2015-01-01');
  converter.convert(eurValue, conversionDate, 'EUR', 'USD', function(err, usdResult) {
    if (err)
      return callback(err);

    console.log('Converted ' + eurValue + ' EUR to ' + usdResult.value + ' USD, according to FX rate of ' . usdResult.usedDate.format('DD.MM.YYYY') );
  });

Important Notes:

  • If the queried day exists in the cache then the library uses the queried day for conversion.
  • If the queried day does not exit the library will try to use the nearst day before.

Tests

npm test

Contributing

Nino Ulsamer, Divvit AB

Release History

  • 2.0.0 Fix currency file updates.
  • 2.0.0 Uses data in-memory and binary-search and includes and enriched response.
  • 1.0.3 Fixed issue #1: round currency conversion results to max 2 digits
  • 1.0.2 Changed default working directory to __dirname
  • 1.0.1 Improved README formatting
  • 1.0.0 Initial release

Keywords

FAQs

Package last updated on 10 Sep 2018

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