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

incremental-number-formatter

v1.0.0

Published

Formats large numbers for incremental games using decimal.js

Readme

incremental-number-formatter

A TypeScript library for formatting large numbers in incremental games. Supports both scientific notation and letter notation (e.g., 1k, 1m, 1b, 1aa, 1zz). It also handles extremely large numbers with precision using decimal.js.

Installation

Install the library via npm:

npm install incremental-number-formatter

Usage

Importing the Library

import { NumberFormatter } from 'incremental-number-formatter';
import Decimal from 'decimal.js';

Creating a Formatter

First, create a reusable formatter with options:

const formatter = new NumberFormatter({
  notation: 'letter', // 'scientific' or 'letter'
  decimals: 2,        // Number of decimal places to display
});

Formatting Numbers

const num = new Decimal(1234567); // 1,234,567
console.log(formatter.format(num)); // "1.23m" (letter notation)

Scientific notation example:

const sciFormatter = new NumberFormatter({
  notation: 'scientific',
  decimals: 2,
});
console.log(sciFormatter.format(num)); // "1.23e+6"

The Letter Formatter

This format is pretty common in incremental games. For "small" numbers, the suffix is k, m, b, or t. Then for "large" numbers, the suffix becomes aa, ab, ..., zz.

If the number exceeds zz (e.g., beyond 1e2042), the library throws an error:

try {
  console.log(formatter.format(new Decimal('1e2043')));
} catch (error) {
  console.error(error.message); // "Exponent too large: ..."
}

Development

Installing

npm install

Building the Library

Run the TypeScript compiler:

npm run build

Testing

Run the tests with Jest:

npm test

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.