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

@typescript-package/currency

v0.1.0

Published

A lightweight package for conversion/exchanges fiat or cryptocurrencies with formatted value.

Readme

typescript-package/currency

npm version GitHub issues GitHub license

A lightweight TypeScript package for conversion/exchanges fiat or cryptocurrencies with formatted value.

Table of contents

Installation

1, Install peer dependencies

npm install
  @typedly/currency
  @typescript-package/range --save-peer

2. Install the package

npm install @typescript-package/currency --save-peer

Api

import {
  // Abstract.
  ConversionBase,
  ConversionCore,
  // Class.
  Conversion,
  Currencies,
  CurrencyValue,
  Exchange
} from '@typescript-package/currency';

Conversion

The concrete class implementation for currency conversion.

import { Conversion } from '@typescript-package/currency';

const conversion = new Conversion(15 as number, 'PLN', { 'USD': 0.275, 'EUR': 0.2347 });

conversion.amount; // 15
conversion.currency; // PLN
conversion.currencies; // ['USD', 'EUR']

conversion.getConversionRates(); // { 'USD': 0.275, 'EUR': 0.2347 }
conversion.conversionRates; // Map([["USD", 0.275], ["EUR", 0.2347 ]]);

// Convert PLN to USD.
conversion.to('USD'); // 4.125
// Convert 15 PLN to EUR.
conversion.to('EUR', 15); // 3.5204999999999997

// Convert USD and EUR to PLN.
conversion.toMany(['USD', 'EUR']); // { USD: 4.125, EUR: 3.5204999999999997 }
// Convert 10 USD and 10 EUR to PLN.
conversion.toMany(['USD', 'EUR'], 10); // { USD: 2.75, EUR: 2.347 }
// Convert and sum USD and EUR.
conversion.sumTo(['USD', 'EUR'], 10); // 5.0969999999999995

// Convert USD to PLN.
conversion.from('USD'); // 54.54545454545454
// Convert custom 15 EUR to PLN.
conversion.from('EUR', 15); // 63.911376224968045

// Convert 10 USD and 10 EUR to PLN.
conversion.fromMany(['USD', 'EUR']); // { USD: 54.54545454545454, EUR: 63.911376224968045 }
conversion.fromMany(['USD', 'EUR'], 10); // { "USD": 36.36363636363636, "EUR": 42.6075841499787 }
conversion.sumFrom(['USD', 'EUR'], 10); // 78.97122051361507

// Set amount to 5 PLN.
conversion.setAmount(5);

// Convert 5 PLN to EUR.
conversion.to('EUR'); // 1.1735

Currencies

The class to store codes of the currencies.

import { Currencies } from '@typescript-package/currency';

CurrencyValue

The currency value class for representing and manipulating monetary values.

import { CurrencyValue } from '@typescript-package/currency';

const value = new CurrencyValue(42345255.356, 'USD');

value.valueOf(); // 42345255.356
value.currency; // USD
value.of; // 42345255.356
value.currencySymbol; // $
value.formatted; // 42,345,255.36
value.getValueAsCurrency('USD'); // $42,345,255.36
value.isBetweenEvery([43345255, 52345255.356], [3500, 127000]); // false
value.lessThan(52345255.356); // true

Exchange

The Exchange class provides functionality to fetch and manage currency exchange rates, and perform conversions using the Conversion class.

import { Exchange } from '@typescript-package/currency';

const exchange = new Exchange(
  15 as number, // number
  'PLN',        // base currency code
  ['USD', 'EUR'], // currencies for exchanges
  { 'USD': 0.275, 'EUR': 0.2347 } // custom exchanges
  // link for exchange api
);

exchange.amount; // 15
exchange.currency; // PLN
exchange.currencies; // ['USD', 'EUR']

exchange.exchangeRates; // { 'USD': 0.275, 'EUR': 0.2347 }

exchange.to('USD').then(result => console.debug(`exchange.to('USD')`, result)); // 4.125
exchange.to('EUR', 15).then(result => console.debug(`exchange.to('EUR', 15)`, result)); // 3.5204999999999997

exchange.from('USD').then(result => console.debug(`exchange.from('USD')`, result)); // 54.54545454545454
exchange.from('EUR', 15).then(result => console.debug(`exchange.from('EUR', 15)`, result)); // 63.911376224968045

Contributing

Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.

Support

If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.

Support via:

or via Trust Wallet

Code of Conduct

By participating in this project, you agree to follow Code of Conduct.

GIT

Commit

Versioning

Semantic Versioning 2.0.0

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

License

MIT © typescript-package (license)

Related packages