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

@polyprism/runtime

v0.3.1

Published

Runtime helpers (normalise + coerce primitives) used by @polyprism/ts-domain-class. The TypeScript-side runtime — only required when you choose the opinionated domain-class pattern. PHP users want the polyprism/runtime Composer package instead. ESM-first

Downloads

1,296

Readme

@polyprism/runtime

Runtime helpers used by @polyprism/ts-domain-class — PolyPrism's opinionated TypeScript domain-class pattern. Part of PolyPrism.

ESM-first, with a CJS sibling for legacy test runners. Zero third-party runtime dependencies. Only required when you choose the TypeScript domain-class pattern. Users of ts-interface, ts-type, and ts-class never see this package.

Looking for the PHP equivalent? The PHP domain-class generator (@polyprism/php-domain-class) is backed by a separate Composer-published runtime, polyprism/runtime on Packagist. It's a different package on a different registry — composer require polyprism/runtime, not npm i @polyprism/runtime — but provides the same set of Coerce and Normalise primitives in PHP shape. See the runtime-php README for the contract.

ESM is the primary contract (import { coerceInt } from "@polyprism/runtime"). Vitest, Jest with --experimental-vm-modules, Bun, Deno, and any modern bundler all resolve to the ESM entry naturally and need no extra configuration.

Using from ts-jest / other CJS test runners

If your test runner loads modules through Node's CJS resolver (default ts-jest, Mocha without an ESM loader, etc.), there are two ways to consume this package. Pick one — both work, the tradeoff is "small config tweak" vs "slightly older code path."

Recommended: let your test runner transform PolyPrism

Add @polyprism/* to your transformIgnorePatterns allowlist so Jest transforms our ESM source the same way it transforms your own:

// jest.config.js / jest.config.ts
export default {
  transformIgnorePatterns: ["/node_modules/(?!@polyprism/)"],
  // ...rest of your config
};

This gives you the modern ESM entry on every code path — same module instance your production code uses, same source maps, no surprises. Recommended whenever you have control over the Jest config.

Fallback: the CJS sibling

If editing Jest config is awkward (vendored config, shared monorepo preset, etc.), the package ships a CJS sibling that require() resolves to automatically — no config needed, it just works:

const { coerceInt } = require("@polyprism/runtime");

The CJS build is a self-contained bundle (no internal require() of ESM siblings), so it loads cleanly under any CJS runtime regardless of Node version or experimental flags.

What it does

Generated domain-class setters apply @normalise and @coerce semantics on assignment by routing through this package instead of inlining the same logic into every model file. That keeps generated code small, the conversion logic centrally tested, and bundle output tree-shakeable.

Public API

import {
  normalise,
  normaliseNullable,
  coerceInt,
  coerceFloat,
  coerceBigInt,
  coerceDate,
  type NormaliseOp,
} from "@polyprism/runtime";

| Export | Purpose | |---|---| | normalise(v, ops) | Apply an ordered list of string-normalisation ops (trim, lowercase, uppercase) to a string | | normaliseNullable(v, ops) | Same but tolerates null and supports the nullEmptyToNull op | | coerceInt(v, fieldPath) | Coerce number \| stringnumber (integer); throws TypeError on invalid input with the field path in the message | | coerceFloat(v, fieldPath) | Coerce number \| stringnumber (float); throws on invalid input | | coerceBigInt(v, fieldPath) | Coerce bigint \| number \| stringbigint; throws on invalid input | | coerceDate(v, fieldPath) | Coerce Date \| string \| numberDate; throws on invalid date | | NormaliseOp | "trim" \| "lowercase" \| "uppercase" \| "nullEmptyToNull" |

Decimal coercion is not in this package — the generated model already imports Decimal from @prisma/client/runtime/library, so its coercion (v instanceof Decimal ? v : new Decimal(v)) is inlined per-model and the runtime stays Prisma-free.

Why a separate runtime package

See the PolyPrism root README for the design rationale: the trade is opt-in per-pattern. Choosing polyprism-ts-domain-class in your schema.prisma adds one runtime dep (@polyprism/runtime) in exchange for setter-driven type laundering, @normalise / @coerce behaviour, and the from() / toJSON() ergonomics — none of which you have to write yourself.

Links

License

MIT © Travis Fitzgerald