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

@quantojs/anything

v0.6.0

Published

One quanto codec that reads anything: dates, money, every quantity, dimensions, coordinates, sizes, CSS colors, pitches, numbers, ratios and odds, with ranges and approximate values, in a curated order.

Readme

@quantojs/anything

One quanto codec that reads anything the first-party packages can: dates, times, money, every quantity, dimensions, coordinates, ring and shoe sizes, CSS colors, pitches, numbers, ratios and odds, ranges of them, infinities, and all of it approximate. It's the big field on quanto's site, as a package.

import { anything } from '@quantojs/anything';
import { phoneNumber } from '@quantojs/anything/phone';

anything().parse('24x36in');      // { value: { codec: 'dimensions(length)', value: [{ value: 24, unit: 'in' }, …] }, approximate: false }
anything().parse('about 6 ft');   // { value: { codec: 'length', value: { value: 6, unit: 'ft' } }, approximate: true }
anything().parse('$10-20k');      // { value: { codec: 'range(money)', value: { start: …, end: … } }, approximate: false }
anything().parse('next fri');     // { value: { codec: 'date', value: '2026-10-02' }, approximate: false }

const withPhones = anything({ include: [phoneNumber()] });
withPhones.parse('(415) 555-2671');   // { value: { codec: 'phoneNumber', value: '+14155552671' }, approximate: false }
  • The value is tagged with the id of the codec that read it: switch on value.codec to know what value.value is. format prints it with that codec.
  • The order settles conflicts. The first codec that reads the text wins, and the others' readings are its alternatives. Dates and times come first, then dimensions, length, mass, duration and temperature, money, pitch, the other quantities, coordinates, sizes and CSS colors, then plain numbers, ratios and odds, then ranges. So 24 × 36 in is dimensions, 455hz a pitch, 3 g grams, 11/4 a date, 25 bps a data rate, US 10 a ring size, 2700 K a temperature (with the color temperature as an alternative) and 70 a number. CSS colors read without bare, so bad and 0 170 255 aren't colors. A trailing odds claims any of them for odds: 11/4 odds, 70 odds. The fixtures pin every conflict.
  • Infinities are tagged with the member their unit or kind names: unlimited GB is { codec: 'dataSize', value: { infinite: 1, unit: 'GB' } }, infinite length is { codec: 'length', value: { infinite: 1 } }, and a bare ∞ is { codec: 'infinite', value: { infinite: 1 } }. Test value.value with isInfinite from quanto.
  • Phone numbers are opt-in with include, since libphonenumber-js's metadata is about 80 kB. phoneNumber is re-exported from @quantojs/anything/phone for convenience, on its own subpath so the main entry never brings the metadata, whatever the bundler. To load it later, await import('@quantojs/anything/phone') and build the codec again with it.
  • include takes any codecs: they're read after the built-in ones and before the catch-alls (numbers, ratios, odds).
  • names adds month and weekday names for dates, as date({ names }) does.
  • Failures are tidied: the first issue of each informative code (unknown_unit, ambiguous, …), or one unparseable.
  • Not included: addresses (an external codec), percent (proportion reads %), text and time signatures (6/8 is a date).
  • Still evolving. The order changes as codecs are added, so what a text reads as can change between releases.

quanto is a peer dependency.