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

@machine202502/types

v1.0.1

Published

Type-level integer math and number utilities for TypeScript

Downloads

34

Readme

@machine202502/types

Type-only TypeScript package with compile-time integer math and number utilities. There is no runtime code — only .d.ts declarations.

Install

npm install @machine202502/types

Requires TypeScript 4.8+ (template literal types / recursive conditional types).

Imports

| Entry | Purpose | |-------|---------| | @machine202502/types/math | Public integer/number math types | | @machine202502/types/math/internal | Lower-level helpers (digit tuples, boolean ops, string utils) |

import type {
  NumberIntegerAdd,
  NumberIntegerMultiply,
  Trunc,
  IsEven,
} from "@machine202502/types/math";

import type { And, Or, If, NumericalSign } from "@machine202502/types/math/internal";

@machine202502/types/math

Number helpers

| Type | Description | |------|-------------| | IsFloat<N> / IsInteger<N> | Whether N looks like a float / integer literal | | IsOdd<N> / IsEven<N> | Parity of truncated N | | Abs<N> / Negate<N> / Sign<N> | Absolute value, negation, sign (-1 \| 0 \| 1) | | Signed<N, S> | Apply sign S (or product of two signs) to Abs<N> | | Trunc<N> | Truncate toward zero via string split (drops fractional part) | | NumberParts<N> | [sign, fixed, float] parts of a number literal |

Integer compare

| Type | Description | |------|-------------| | NumberIntegerCompare<L, R> | -1 \| 0 \| 1 | | NumberIntegerEq / Neq / Gt / Gte / Lt / Lte | Boolean comparisons | | NumberIntegerMin / Max / Clamp | Min, max, clamp (values are truncated) |

Integer arithmetic

Operands are truncated to integers. Results are literal number types.

| Type | Description | |------|-------------| | NumberIntegerAdd<L, R> | L + R | | NumberIntegerSubtract<L, R> | L - R | | NumberIntegerMultiply<L, R> | L * R | | NumberIntegerDivide<L, R> | [quotient, remainder] or null on divide-by-zero | | NumberIntegerPower<N, P> | N ** P (null if P < 0) |

type A = NumberIntegerAdd<32, NumberIntegerMultiply<11, 11>>; // 153
type P = NumberIntegerPower<2, 32>; // 4294967296
type D = NumberIntegerDivide<100, 3>; // [33, 1]
type T = Trunc<-234.601>; // -234

@machine202502/types/math/internal

Building blocks used by the public API. Prefer @machine202502/types/math in app code.

| Group | Types | |-------|--------| | Boolean | ToBoolean, Not, And, Or, If | | Primitives | NumericalDigit, NumericalDigitChar, NumericalSign, NumericalCompared, NumericalUintStringTuple | | String | StringLength, StringToTuple | | Uint digit math | NumberUintStringTupleAdd / Subtract / Multiply / Divide / Half / Power / Compare, NumberUintStringZeroLeftTrim, NumberUintStringZarr*, conversion helpers |

Examples

Runtime wrappers that return these types live in examples/:

  • examples/example-module.ts — functions whose return types are the package types
  • examples/example.ts — end-to-end check (npm run example)
import type { NumberIntegerMultiply } from "@machine202502/types/math";

function Multiply<L extends number, R extends number>(
  l: L,
  r: R,
): NumberIntegerMultiply<L, R> {
  return (Math.trunc(l) * Math.trunc(r)) as NumberIntegerMultiply<L, R>;
}

const n = Multiply(11, 11);
//    ^? const n: 121