npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

xchanger

v0.1.5

Published

Currency exhange api with auto caching of api calls for better performance and bandwidth utilization

Readme

               __
              /\ \
   __  _   ___\ \ \___      __      ___      __      __   _ __
  /\ \/'\ /'___\ \  _ `\  /'__`\  /' _ `\  /'_ `\  /'__`\/\`'__\
  \/>  <//\ \__/\ \ \ \ \/\ \L\.\_/\ \/\ \/\ \L\ \/\  __/\ \ \/
   /\_/\_\ \____\\ \_\ \_\ \__/.\_\ \_\ \_\ \____ \ \____\\ \_\
   \//\/_/\/____/ \/_/\/_/\/__/\/_/\/_/\/_/\/___L\ \/____/ \/_/
                                             /\____/
                                             \_/__/

Description

Currency converter with auto caching of exchange rates from exchangeratesapi.io

Usage

Its really simple to use. Just require the module and create a new xchange instance.

  const XCHANGER = require('xchanger')
  const xchange = new XCHANGER() // or new XCHANGER(<currency code>)

  xchange.setBase('inr') //Set the base exchange currency to use as a default

  // Convert to currency specified as base currency

  xchange.convert(100, 'usd').then(result => {
    // Since we specified INR as base
    // the converted result will be in INR
    console.log(result)
  }).catch(error => {
    console.log(error)
  })

  // Convert from usd to aud
  xchange.convert(100, 'usd', 'aud').then(result => {
    console.log(result)
  }).catch(error => {
    console.log(error)
  })

  // Get a list of supported currency codes
  xchange.getValidCodes()

Functions

The module itself exports a constructor from which and exchange object can be created. Each exchange object has the following methods available -

  • sync() : Fetches the latest rates from the api. Returns a promise
  • saveRates() : Stores the rates to a local .json file. Returns a promise
  • loadRates() : Reads the rates from the local .json file. Returns a promise
  • setBase() : Sets the base exchange rate. (Available as the 'base' attribute of the object)
  • getBase() : Gets the current base exchange rate set on the xchange
  • getValidCodes() : Returns a list of accepted Currency Codes
  • isValidCC() : Checks if a given Currency Code is valid for use
  • convert() : Converts a given amount from one currency to another

Supported Currencies

Currently the api provides support for the 33 currencies listed below -

  • Australian Dollar (AUD)
  • Bulgarian Lev (BGN)
  • Brazilian Real (BRL)
  • Canadian Dollar (CAD)
  • Swiss Franc (CHF)
  • Chinese Yuan Renminbi (CNY)
  • Czech Koruna (CZK)
  • Danish Krone (DKK)
  • European Union Euro (EUR)
  • Great Britain Pound (GBP)
  • Hong Kong Dollar (HKD)
  • Croatian Kuna (HRK)
  • Hungarian Forint (HUF)
  • Indonesian Rupiah (IDR)
  • New Israeli Sheqel (ILS)
  • Indian Rupee (INR)
  • Iceland Krona (ISK)
  • Japanese Yen (JPY)
  • Korean Won (KRW)
  • Mexican Peso (MXN)
  • Malaysian Ringgit (MYR)
  • Norwegian Krone (NOK)
  • New Zealand Dollar (NZD)
  • Philippine Peso (PHP)
  • Polis Zloty (PLN)
  • Romanian Leu (RON)
  • Russian Ruble (RUB)
  • Swedish Krona (SEK)
  • Singapore Dollar (SGD)
  • Thailand Baht (THB)
  • Turkish Lira (TRY)
  • United States Dollar (USD)
  • Rand (ZAR)

Thats it!

DISCLAIMER

This module uses exchangeratesapi.io to fetch rates and caches them for 30 minutes. There is no functionality to reduce that time as of now. Therefore, the converted results from this module may vary from the real time results. Furthermore, the fact that it depends on the external API means the author has no control over the rates returned and is therefore not liable for any damage, loss or failure due to the use of this module.

POST DISCLAIMER

All that being said, if you are looking to convert currencies with reasonable accuracy and real time isnt really your use case, then go to town with this.

Author

Created and maintained by Hanut Singh Gusain

My Links