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

@smartput/core

v0.3.0

Published

The engine: normalize, tokenize, parse, solve, eval, print.

Readme

@smartput/core

The engine: normalize, tokenize, parse, solve, eval, print.

Everything that turns text into a Result, and nothing that knows what a metre is. createEngine() composes locales and kinds into the six-stage pipeline; defineKind() and defineLocale() are how anything gets into it.

One runtime dependency, decimal.js, and that is a deliberate ceiling — check-deps.ts fails the build if a second one appears. Every stage is also its own subpath, so a consumer that wants only the tokenizer pays for only the tokenizer.

Setup

npm add @smartput/core

Example

import { composeLocale, createEngine } from "@smartput/core";
import { english } from "@smartput/core/locale/en";
import { BUILTIN_KINDS } from "@smartput/kinds";
import BUILTIN_EN from "@smartput/kinds/locale/en";

const engine = createEngine({
  locales: [composeLocale(english, BUILTIN_EN)],
  kinds: BUILTIN_KINDS,
});

engine.evaluate("1 kg + 500 g").formatted         // "1.5 kilograms"
engine.evaluate("2 km in m").formatted            // "2,000 metres"
engine.evaluate("20% of 250").formatted           // "50"
engine.evaluate("1 kg + 500 g").confidence        // 1
engine.complete("12 k").length                    // 10
engine.explain("10 m + 5 min").candidates.length  // 1

evaluate returns a Result — value, formatted, kind, confidence, spans, meta — and never throws on unreadable input. explain() returns the same run with every stage's intermediate state, which is what to reach for when a reading is not the one you expected.

Entry points

| Import | Contents | | --- | --- | | @smartput/core | The package root. | | @smartput/core/testing | assertKindContract — the contract every kind must satisfy. | | @smartput/core/normalize | Stage 1: case, spacing, digits, punctuation. | | @smartput/core/tokenize | Stage 2: text to Token[]. | | @smartput/core/parse | Stage 3: tokens to candidate readings. | | @smartput/core/solve | Stage 4: ranking, ambiguity, weights. | | @smartput/core/scan | See the source for what this subpath carries. | | @smartput/core/eval | Stage 5: the arithmetic, in Decimal. | | @smartput/core/print | Stage 6: formatValue and the locale number grammar. | | @smartput/core/registry | The kind/locale registry the stages read. | | @smartput/core/locale/<id> | One language's words for this kind. 17 ship: en, de, fr, es, pt, it, nl, zh, ja, ar, ru, pl, tr, hi, ko, id, uk. |

Runtime exports

Type-only exports are erased and do not appear here.

AmbiguityError · Autocompleter · BOOLEAN_KIND · BOOLEAN_UNIT · COMPARE_PRECISION · COMPARISON_OPS · CUE_CEILING · CountQueryError · DEFAULT_CUE_WINDOW · DEFAULT_DISPLAY · DEFAULT_MAX_SPAN · DISPLAY_PRECISION · Decimal · DimensionMismatchError · DivideByZeroError · EDIT_HEADROOM · EXACT_BONUS · Evaluator · KeywordConflictError · KindConflictError · LENGTH_PENALTY · LocaleMismatchError · MissingRateError · NUMBER_FALLBACK_WEIGHT · NUMBER_KIND · NoCandidateError · Normalizer · PERCENT_KIND · Parser · Printer · RateProviderError · RatesNotReadyError · SCALE_BONUS · Scanner · SmartputError · Solver · Tokenizer · TooAmbiguousError · UnitParseError · UnknownKindError · VocabularyConflictError · aliasesFor · applyDisplay · buildKeywords · buildProgram · buildRegistry · cardinalNumerals · cardinalSpeller · collectCues · complete · composeLocale · compoundSplitter · createAnalyzerChain · createCachedEngine · createEngine · createFacade · createFacades · createSnapshotCache · decimalRatios · defineKind · defineLanguage · defineVocabulary · deriveValue · editDistance · evaluateNode · foldLiterals · formatNumber · formatValue · generateComparisonOps · identity · nearestWord · normalize · phraseAnalyzer · prefixStripper · scriptSegmenter · solve · suffixStripper · tableAnalyzer · walk · wordsFor

Dependencies


Generated by scripts/gen-readmes.ts — run bun run docs:readmes. Every output above was produced by running the line beside it. The full page, with live demos, is docs/packages/core.md.