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

@isentropic/dim-quantity

v0.4.3

Published

Define quantity systems for compile-time dimensional analysis

Readme

@isentropic/dim-quantity

Define quantity systems for compile-time dimensional analysis.

Looking for standard ISQ quantities? See @isentropic/dim-isq.

Usage

Spec-based

The preferred approach for any non-trivial system. Define a spec, generate typed factories, and use them.

// quantities.spec.ts
import { defineQuantitySpec } from "@isentropic/dim-quantity/generate";

export default defineQuantitySpec({
  name: "physics",
  dims: ["L", "T"],
  quantities: {
    base: {
      length: "L",
      time: "T",
    },
    derived: {
      velocity: { L: 1, T: -1 },
      area: { L: 2 },
    },
  },
});

Generate the code:

deno run -RW jsr:@isentropic/dim-quantity/generate \
  --spec ./quantities.spec.ts \
  --out ./quantities.generated.ts

Use the generated factories:

import { area, length, time, velocity } from "./quantities.generated.ts";
import { add, divide, multiply } from "@isentropic/dim-quantity/ops";

const distance = length(100);
const duration = time(10);

const speed = divide(distance, duration);
const surface = multiply(length(5), length(5));
const total = add(length(50), length(30));

// Dimension mismatches are compile errors
// add(length(10), time(5));     // Can't add length and time

For Node/Bun, use generateQuantitySystem() programmatically:

import { generateQuantitySystem } from "@isentropic/dim-quantity/generate";
import { writeFileSync } from "node:fs";
import spec from "./quantities.spec.ts";

writeFileSync("./quantities.generated.ts", generateQuantitySystem(spec));

Code-based

For small, one-off quantity systems where code generation isn't worth the overhead:

import { defineQuantitySystem } from "@isentropic/dim-quantity";
import { add, divide } from "@isentropic/dim-quantity/ops";
import type { DimOf } from "@isentropic/dim-quantity";

const qs = defineQuantitySystem(["L", "T"]);

const length = qs.base("L");
const time = qs.base("T");
const velocity = qs.factory({ L: 1, T: -1 });

// Extract dimension types from factory functions
type Length = DimOf<typeof length>;
type Velocity = DimOf<typeof velocity>;

const distance = length(100);
const duration = time(10);
const speed = divide(distance, duration);

// Dimension mismatches are compile errors
// add(distance, duration);     // Can't add length and time

Installation

# Deno
deno add jsr:@isentropic/dim-quantity
# npm
npm install @isentropic/dim-quantity
# Bun
bun add @isentropic/dim-quantity

License

MIT