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

quanto

v0.6.0

Published

The quanto protocol: turn messy human text into well-typed values and back. Codec contracts, definition helpers, context, issues, composition and shared parsing primitives. The codecs are in @quantojs/common.

Readme

quanto

Turn messy human text into well-typed values and back: 5'11", 180cm and 1,8 m all parse into the same typed length, which can be converted, compared and formatted. The same idea covers weights, durations, temperatures, percentages and custom types.

quanto is the protocol: codec contracts, definition helpers, context, issues, composition and shared parsing primitives. It has no codecs. Install the codecs you need alongside it: the common ones (quantities, numbers, money, odds, text) are in @quantojs/common.

Pre-release. The design and its open questions are in the repository's DESIGN.md. Money is in @quantojs/common/money, betting odds in @quantojs/common/odds, and dates and times in @quantojs/datetime.

Using quanto

Read this before using quanto in an app. To write a codec, read AUTHORING.md.

Parse, then check ok

import { length } from '@quantojs/common';

const height = length({ defaultUnit: 'in' });
const result = height.parse(text, { locale: 'en-GB' });

if (result.ok) {
  result.value;    // { value: 71, unit: 'in' }
} else {
  result.issues;   // [{ code: 'unknown_unit', message: '…' }]
}

parse never throws on bad input. Show issues to the user; localize by code, not message.

Store { raw, value }

if (result.ok) save({ raw: text, value: result.value });
  • value is authoritative. Read it, compute with it, send it to the server.
  • raw is what the user typed. Keep it so re-editing shows their text, and for audits.
  • Never re-parse raw to get the value back. Relative input (tomorrow) would give a different answer.
  • On the server, validate value with codec.schema (a Standard Schema) and store its output. Don't parse on the server.
  • To display stored values that may be malformed, use formatWithFallback(codec, value, fallback). format throws on them.

Optional extras

  • result.context ({ locale, now? }): what the parse was based on. Store it separately, only if you need to replay a parse later (audits, debugging, migrations): codec.parse(raw, context) reproduces the value on the same versions of quanto and the package that owns the codec (@quantojs/common for lengths, @quantojs/datetime for dates).
  • { raw, issues }: a field that didn't parse. Usually you block the submit instead of storing it. Keep it only for drafts, where the user's bad text must survive.

External codecs

An external codec (defineExternalCodec) parses through a service: a model, a server, a worker. Its parse returns a Promise; format and schema are sync, as for any codec.

  • Bad input resolves with issues; a failed service rejects. Don't store an outage as issues: keep the text and retry when it suits you.
  • Pass ctx.signal to cancel a parse in flight. It rejects with signal.reason.
  • It owns its whole parse. merge, range, approx and infinite don't take one; optional does.
  • Store { raw, value } exactly as above. In React, use QuantoInput or useExternalQuanto from @quantojs/react.

Pass context on the server

In a browser, omit ctx.now: the machine clock is what the user means. When parsing on a user's behalf on a server, pass the user's locale and now (with their UTC offset), or tomorrow resolves in the server's time zone.