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

decimal-idk

v0.1.0

Published

A precision numeric library for TypeScript/JavaScript, backed by `bigint` for arbitrary-precision decimal arithmetic. Single file, zero runtime dependencies, optimized. Observed performance is 2x faster than `decimal.js`. It works for my use case, but it

Readme

decimal

A precision numeric library for TypeScript/JavaScript, backed by bigint for arbitrary-precision decimal arithmetic. Single file, zero runtime dependencies, optimized. Observed performance is 2x faster than decimal.js. It works for my use case, but it is not meant to be a drop-in replacement for decimal.js.

Features

  • Exact decimal arithmetic — no floating-point drift
  • BigInt-backed internals — configurable precision (default 20 digits)
  • Full math API — arithmetic, comparison, trigonometry, logarithms, exponentials, power
  • Object pool — pre-allocated instance pool (10,000 slots) to minimize GC pressure
  • LRU cachesexp, ln, sqrt, pow results cached for hot paths
  • decimal.js-compatible interface — familiar API, limited set of functions, precision control is different. The range is limited by the precision u set and bigint max size.

Install

pnpm install decimal

Usage

import { Decimal } from "decimal";

// Configure precision
Decimal.setPrecision(30); // sets global precision to 30 digits after the decimal point, N.[30] digits. N can be of any length
Decimal.setPrecision(-3); // sets global precision to 3 digits before the decimal point, N000. N can be of any length.

// Arithmetic
const a = Decimal("1.1");
const b = Decimal("2.2");
const sum = a.plus(b); // "3.3"  (exact)
const prod = a.times(b); // "2.42"

// Aliases: add/plus/sum, sub/minus, mul/times, div/divide

// Comparison
a.lt(b); // true
a.gt(Decimal("0.5")); // true

// Rounding
Decimal("3.14159").round(); // "3"
Decimal("3.14159").floor(); // "3"
Decimal("3.14159").ceil(); // "4"

// Transcendental functions
Decimal.exp("1"); // e
Decimal.ln("100"); // natural log
Decimal.sqrt("2"); // square root
Decimal.pow("2", "0.5"); // power

// Trigonometry (radians)
Decimal.sin("3.141592653589793");
Decimal.cos("0");
Decimal.tan("0.5");

// Static multi-argument helpers
Decimal.add("1", "2", "3"); // "6"
Decimal.times("2", "3", "4"); // "24"
Decimal.min("3", "1", "2"); // "1"
Decimal.max("3", "1", "2"); // "3"

API

Construction

| Syntax | Description | | ----------------------- | ----------- | | Decimal("1.23") | From string | | Decimal(1.23) | From number | | Decimal(otherDecimal) | Clone |

Static Configuration

| Method | Description | | -------------------------- | ---------------------------------- | | Decimal.setPrecision(n) | Set global precision (default 20) | | Decimal.setNotation(sci) | Enable/disable scientific notation | | Decimal.setPoolSize(n) | Resize the object pool |

Instance Methods

| Category | Methods | | ------------------ | -------------------------------------------------------------------------------------------------- | | Arithmetic | add, plus, sum, sub, minus, mul, times, div, divide, neg, abs, sqrt, pow | | Transcendental | ln, exp, sin, cos, tan, asin, acos, atan | | Rounding | round, floor, ceil, toPrecision(n), toFixed(n) | | Comparison | lt, lte, gt, gte, eq, neq, compare | | Checks | isZero, isNegative, isPositive, isInteger, isNaN | | Conversion | toString(), toNumber(), toJSON(), clone() |

Static Functions

Decimal.ln, Decimal.exp, Decimal.sqrt, Decimal.pow, Decimal.sin, Decimal.cos, Decimal.tan, Decimal.asin, Decimal.acos, Decimal.atan, Decimal.abs, Decimal.add, Decimal.times, Decimal.sub, Decimal.div, Decimal.min, Decimal.max, Decimal.random, Decimal.isPositive, Decimal.isNegative

Static vs Instance

Both forms are supported. Decimal.exp("2.718") is equivalent to Decimal("2.718").exp().

Precision

Global precision controls all operations. Set once at startup:

Decimal.setPrecision(30); // 30-digit precision

Build & Test

pnpm run build   # TypeScript compilation
pnpm test        # Run tests

License

MIT