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

@soldi/core

v0.4.2

Published

A simple currency library

Downloads

5

Readme

@soldi/core

Soldi is a simple currency manipulation library for safely calculating with monetary values in JavaScript.

codecov quality dependencies npm (scoped) GitHub npm bundle size (scoped) Snyk Vulnerabilities for npm scoped package

Benefits of Soldi

  • Fluent, immutable, and chainable API
  • Easily extensible, with several extensions already written
  • Overflow detection
  • Currency exchange features
  • Formatting Options via Extensions
  • 100% test coverage
  • Enthusiastic maintainer open to community contributions

Installation

For new users we recommend using @soldi/core directly.

npm install @soldi/core

or

yarn add @soldi/core

Usage

Soldi makes it easy to create and calculate using monetary values.

Amounts are specified in minor currency units (e.g.: "cents" for the dollar). You must also specify a currency. We suggest using ISO 4217 currency codes, but you are free to use anything you want.

For example to construct €1:

let oneEuro = Soldi({ amount: 100, currency: 'EUR' });

You can add and subtract amounts provided they have the same currency:

// returns a Soldi object with amount: 600 and currency 'EUR'
oneEuro.add(Soldi({ amount: 500, currency: 'EUR' }));
// returns a Soldi object with amount: 4500 and currency 'EUR'
price.subtract(Soldi({ amount: 500, currency: 'EUR' }));

Soldi is immutable, which means you always receive a new Soldi instance when you perform any operation on it. The original instance is unmodified by any operation.

All transformative operations return a Soldi instance, so you can chain methods to perform a series of operations.

// Calculates ( 50 + 50 ) * 4 => 400
// not: 50 + 50 * 4 => 250
// as would be expected using normal operator precedence
Soldi({ amount: 50, currency: 'EUR' })
  .add(Soldi({ amount: 50, currency: 'EUR' }))
  .multiply(4);

Operations are executed in the chained order, so operator precedence is as written in the chain, not as it would be for an equivalently expressed mathematical expression.

You can also introspect your Soldi instance in various ways:

// returns true
Soldi({ amount: 500, currency }).isEqualTo(Soldi({ amount: 500, currency }));

// returns false
Soldi({ amount: 100, currency }).isZero();

// returns true
Soldi({ amount: 50, currency }).hasSubUnits();

Soldi can also be constructed with a precision, which tells Soldi how many sub-units the currency supports, or to support more sub-units than is common for the currency. For example if you wanted to create a system capable of accounting hundredths of a cent, you could use a higher precision soldi to do the calculations.

const onePreciseEuro = Soldi({ amount: 10000, precision: 4, currency });

Soldi also handles mixing precisions, and promotes lower precision numbers to the highest precision amongst the Soldi in the operations.

// Returns Soldi { amount: 20000, precision: 4, currency: 'EUR' };
onePreciseEuro.add({ amount: 100, currency });

For most currencies, Soldi will infer the default precision for that currency, if it is known, and will not include precision in the toObject() version of the Soldi to save storage space if it matches what Soldi would infer from the currency.

Finally, Soldi is easily extensible to offer additional features. See the source code for: @soldi/locale or @soldi/dinero for examples of how to extend Soldi with additional features. If your extension would be of bennefit to others, consider opening a PR to add your extension to @soldi directly.