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

@billdaddy/mathkit

v0.1.1

Published

Tiny, type-safe scalar math utilities — clamp, lerp, remap, smoothstep, precise round, wrap, gcd/lcm, and more. Zero dependencies.

Readme

mathkit

All Contributors

Tiny, type-safe scalar math utilities — clamp, lerp, remap, smoothstep, precise round, wrap, gcd/lcm, and more. Zero dependencies.

CI npm version bundle size types license

Math gives you min, max, and round — but every UI, chart, game, and animation also needs clamp, lerp, a remap between ranges, and a round that doesn't trip on 1.005. mathkit is that missing scalar toolbox, fully typed and tree-shakeable.

import { clamp, lerp, remap } from "@billdaddy/mathkit";

clamp(volume, 0, 1);                 // keep in range
lerp(start, end, t);                 // animate
remap(scrollY, 0, 800, 1, 0.4);      // map scroll → opacity

Why mathkit?

  • The everyday helpers. clamp, clamp01, lerp, inverseLerp, remap, smoothstep, smootherstep.
  • Rounding done right. round(1.005, 2) === 1.01 (the naive * 100 trick gives 1); plus roundTo for nearest-multiple snapping.
  • Float-safe comparisons. isClose uses combined absolute + relative tolerance, so 0.1 + 0.2 ≈ 0.3 and large numbers compare sanely.
  • Angles & wrapping. degToRad/radToDeg and a wrap that handles negatives and arbitrary ranges (great for angles and looping indices).
  • Number theory. gcd, lcm.
  • Tree-shakeable. sideEffects: false, ESM + CJS, zero dependencies.

Install

npm install @billdaddy/mathkit
# or: pnpm add @billdaddy/mathkit  /  yarn add @billdaddy/mathkit  /  bun add @billdaddy/mathkit

Interpolation

import { clamp, clamp01, lerp, inverseLerp, remap, smoothstep } from "@billdaddy/mathkit";

clamp(15, 0, 10);          // 10   (swapped bounds are tolerated)
clamp01(1.5);              // 1
lerp(0, 100, 0.25);        // 25   (t is not clamped)
inverseLerp(0, 100, 25);   // 0.25
remap(5, 0, 10, 0, 100);   // 50
smoothstep(0, 1, 0.25);    // 0.15625 (eased, clamped)

Rounding & comparison

import { round, roundTo, isClose } from "@billdaddy/mathkit";

round(1.005, 2);     // 1.01
round(1234.5678, -2); // 1200
roundTo(0.27, 0.05); // 0.25
isClose(0.1 + 0.2, 0.3); // true
isClose(1, 1.05, 0.1);   // true (custom tolerance)

Angles, wrapping, number theory

import { degToRad, radToDeg, wrap, gcd, lcm } from "@billdaddy/mathkit";

degToRad(180);        // 3.14159…
wrap(370, 0, 360);    // 10
wrap(-30, 0, 360);    // 330
gcd(12, 18);          // 6
lcm(4, 6);            // 12

Pairs well with

| Need | Use | | --- | --- | | Reduce arrays (sum, mean, minBy…) | @billdaddy/arraykit | | Human-format numbers (1.2K, bytes) | humankit |

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT © Tung Tran