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 🙏

© 2026 – Pkg Stats / Ryan Hefner

graphology-currency-exchange

v1.0.1

Published

Implementation over graphology for currency conversion with 1:n values for each conversion. Package takes care of reversing the exchange but works with the quick-and-dirty graph to get to all currencies

Downloads

4

Readme

Proof of concept project for Currency Exhange using graphs for Job Manager

Base libray: https://graphology.github.io/

What this package is aimed to solve

Suppose you have to convert rom a local currency to a foreign currency and you keep different values per each currency (e.g.: tourism and commercial rates).

This is as yeasy as multiplying the origin currency to the destination currency.

The problem starts when you need to use two currencies which don't have direct conversions, AKA wick currencies, like Brazillian Real and Japanese YEN.

So you'll need an intermediary currency, such as USD or EUR or GBP. In that case you could convert your destination currency for one of those and then back to your original currency.

In the sample above, 1 YEN = 0.0088 USD (today 2021-11-16). So, to get the value in USD you would get your 1 YEN item and multiply by 0.0088 = 0.0088 USD

Now you need to convert it to BRL (Brazillian Real) As of today, 1 USD is equivalent to 5.46. Therefore, your cost of 0.0088 USD becomes 0.0088 * 5.46 = BRL 0.048048

Keeping track of this currencies can be a bug challenge, to solve this issue, I've created this library, in which you can create your currencies and conversions and it will handle all the possible conversions AS YOU REQUEST IT and store back to the graph.

It is based in Graphology package.

Installing

npm install graphology --save
npm install graphology-types --save

Running

ts-node tests/approach.ts #basic approach showing how the algorithm works
ts-node tests/dynamicApproach.ts

Sample

Consider this graph

BRL <-> USD USD <-> EUR CAD <-> USD BRL <-> EUR CAD <-> EUR

Our goal here is, given a base currency and a destination currency, be able to know: a) is there a possible path to get from currency source to currency destination (e.g.: CAD -> BRL) b) get the correct exchange rate or fail

In the graph defined above, it is possible to get from CAN to BRL, passing through USD (CAD -> USD -> BRL).

The approach will be to first find a way to do it. You might note that CAD -> EUR -> BRL is also a possible approach, however as described above I'm not interested in this path right now