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

@puvaanraaj/moneta

v0.1.0

Published

Immutable, BigInt-precision monetary values for TypeScript. No float errors. Currency-safe by design.

Readme

moneta

Immutable, BigInt-precision monetary values for TypeScript. No float errors. Currency-safe by design.

CI npm npm bundle size License: MIT

Why moneta?

Every JavaScript app that handles money eventually hits the float trap:

0.1 + 0.2 === 0.3 // false — 0.30000000000000004

moneta solves this permanently using native BigInt under the hood — no floats, ever. It also catches currency mismatches at the TypeScript type level, not at runtime.

const usd = money('10.00', 'USD')
const eur = money('5.00',  'EUR')

usd.add(eur) // TypeError — caught at compile time, not in production

Install

npm install moneta

Requires Node ≥ 18. Zero runtime dependencies.

Quick start

import { money } from 'moneta'

const price = money('19.99', 'USD')
const tax   = money('1.60',  'USD')

price.add(tax).format('en-US')       // "$21.59"
price.multiply(1.1).format('en-US')  // "$21.99"
price.divide(3).format('en-US')      // "$6.66"

// Allocate $10 in 3 parts — sum always equals original
money('10.00', 'USD').allocate([1, 1, 1])
// [Money('3.34 USD'), Money('3.33 USD'), Money('3.33 USD')]

API

money(amount, currency)

The primary factory. Returns an immutable Money<C> instance.

money('19.99', 'USD')   // from string  — recommended
money(19.99, 'USD')     // from number  — uses toFixed() internally
money(1999n, 'USD')     // from bigint  — treated as minor units (cents)

Money.fromMinorUnits(units, currency)

Create from raw minor units — useful when reading from a database.

Money.fromMinorUnits(1999n, 'USD') // $19.99

Arithmetic

All operations return a new Money instance (immutable).

| Method | Description | |---|---| | .add(other) | Add two same-currency values | | .subtract(other) | Subtract two same-currency values | | .multiply(factor) | Multiply by a scalar (number or string) | | .divide(divisor) | Divide by a scalar, half-up rounding | | .allocate(ratios) | Proportional split — sum always exact | | .abs() | Absolute value | | .negate() | Flip sign |

Comparison

a.equals(b)
a.greaterThan(b)
a.lessThan(b)
a.greaterThanOrEqual(b)
a.lessThanOrEqual(b)
a.isZero()
a.isPositive()
a.isNegative()

Accessors

m.currency       // 'USD'
m.minorUnits     // 1999n  — safe for DB storage
m.decimalValue   // '19.99'

Formatting

m.format()         // uses default locale
m.format('de-DE')  // "19,99 $"
m.format('ja-JP')  // "$19.99"

Serialisation

m.toJSON()
// { amount: '19.99', currency: 'USD', minorUnits: '1999' }

JSON.stringify(m)
// '{"amount":"19.99","currency":"USD","minorUnits":"1999"}'

m.toString()  // '19.99 USD'

Supported currencies

34 ISO 4217 currencies included: AED, AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, JPY, KRW, KWD, MXN, MYR, NOK, NZD, PHP, PLN, RON, SAR, SEK, SGD, THB, TRY, TWD, USD, VND, ZAR.

Error handling

All errors extend MonetaError and are typed:

import {
  CurrencyMismatchError,
  DivisionByZeroError,
  InvalidAmountError,
  UnknownCurrencyError,
} from 'moneta'

Security

  • Zero runtime dependencies
  • No eval, no dynamic code execution
  • No install scripts — safe against supply-chain attacks
  • Every npm release is published with provenance (SLSA Level 2)
npm audit signatures  # verify the package wasn't tampered with

See SECURITY.md for the full policy and how to report vulnerabilities.

License

MIT