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

quickertype-core

v0.3.0

Published

quicktype's quicktype-core API with a WebAssembly engine compiled from its Rust port: a drop-in replacement for quicktype-core

Readme

quickertype-core

quicktype's quicktype-core API with its engine compiled to WebAssembly from the Rust port quickertype. The API, the .d.ts files and the generated code are quicktype's own, apart from the fixes of a few bugs in the code quicktype generates.

Install

npm install quickertype-core

Node.js 20 or later, or a browser.

Use

It is a drop-in replacement for quicktype-core: change the import.

import { quicktype, InputData, jsonInputForTargetLanguage } from "quickertype-core";

const input = jsonInputForTargetLanguage("typescript");
await input.addSource({ name: "Person", samples: ['{"name": "Ann", "age": 7}'] });
const inputData = new InputData();
inputData.addInput(input);
const { lines } = await quicktype({ inputData, lang: "typescript" });

JSON samples as bytes

The JSON inputs of jsonInputForTargetLanguage also take a sample as its UTF-8 bytes: a Uint8Array, or a Node.js Buffer, also one from another realm (a vm context, an iframe). This is an addition to quicktype-core's API. A sample given as bytes is the text that new TextDecoder().decode(bytes) gives, which is also what a browser's file.text() gives for a file: a leading byte order mark is not part of the text, and every sequence that is not UTF-8 becomes U+FFFD. The engine reads the bytes as they are, without a JavaScript string in between. A string sample has to be decoded into a string first, then encoded again into the engine's memory.

import * as fs from "node:fs";
import { jsonInputForTargetLanguage } from "quickertype-core";

const input = jsonInputForTargetLanguage("typescript");
await input.addSource({ name: "Cards", samples: [fs.readFileSync("cards.json")] });

In a browser, use new Uint8Array(await file.arrayBuffer()). Bytes can also hold a file too large to be a JavaScript string, which in V8 is about 2^29 UTF-16 code units. The bytes are read when addSource is called, so changing them afterwards changes nothing. On the TypeScript engine (see below), the bytes are decoded first, then parsed with JSON.parse. Bytes that are not UTF-8 are decoded once either way, and what the decoder throws (a RangeError for a text longer than the longest string) is addSource's error, as on the TypeScript engine.

JSON Lines

The JSON inputs also read JSON Lines (NDJSON), which quicktype does not: give a source jsonLines: true, and each of its samples is JSON Lines text, one JSON value per line, read as the JSON array of those values. The output is what quicktype gives for that array, byte for byte, in every language and with every option, as with the CLI's JSON Lines (README). This is an addition to quicktype-core's API: without jsonLines, a sample is one JSON value, as in quicktype.

import * as fs from "node:fs";
import { InputData, jsonInputForTargetLanguage, quicktype } from "quickertype-core";

const input = jsonInputForTargetLanguage("typescript");
await input.addSource({ name: "Cards", samples: [fs.readFileSync("cards.jsonl")], jsonLines: true });
const inputData = new InputData();
inputData.addInput(input);
const { lines } = await quicktype({ inputData, lang: "typescript" });
  • A sample is a string or its UTF-8 bytes (as above), each a whole JSON Lines document; several samples are several documents, each read as one array, as several array samples would be. addSourceSync takes jsonLines too, and in TypeScript it is JSONSourceData.jsonLines.
  • Line breaks are \n or \r\n; blank lines are skipped, the last line break is optional, a value may span lines, a byte order mark may come first, and two values on one line are an error. A sample without values is [], and one with a single value an array of one.
  • Each value is read as JSON.parse reads a JSON sample. A syntax error names the line its value starts on, followed by JSON.parse's message for that value, whose positions count from the value's start (V8's (line L column C) is left out): Syntax error in input JSON Cards: line 3: Expected ',' or '}' after property value in JSON at position 9. A second value on a line is line N: Unexpected non-whitespace character after JSON, without a position, as the CLI's error has none. The CLI names the same lines; its messages after them are quicktype's CLI's, which reads files with another parser. A sample that fails adds nothing to the input: the tables are as before it.
  • The engine reads JSON Lines as fast as the same values as an array, and bytes as they are. Where it does not read them (the TypeScript engine, bytes that are not UTF-8, see below), each value is decoded and parsed by itself and handed to the input as soon as it is parsed, so that neither the text of a large sample nor all its values are ever held at once, and bytes too large to be one string can be read too. A value too long to be one string is that error (line N: the value is too long to be one JavaScript string …), not a syntax error.
  • JSON Lines are read by a CompressedJSONFromString (what jsonInputForTargetLanguage makes, or a subclass of it) whose parse and parseSync are its own: JSON Lines do not go through them, but through pushArrayContext, process (once per value), finishArray and finish, which a subclass may override. With any other CompressedJSON, or a subclass that overrides parse or parseSync, addSource throws a plain Error that says so, before reading any sample (not quicktype's "Syntax error" about a sample's text).

require("quickertype-core") works too. The package matches quicktype-core 24.0.0 at quicktype commit c39af7d3 (src/native/UPSTREAM.json); its own version (0.1.0) is quickertype's, not quicktype's. In a browser the engine is a separate .wasm file that your bundler has to serve, or that you hand over yourself: see Loading. Try it in the playground.

The rest of this file is about how the package works and how to build it.

How it works

src/ is quicktype's packages/quicktype-core/src at the commit in src/native/UPSTREAM.json, byte for byte, except three files: Run.ts, which after preRun() hands the run to the engine (src/native/bridge.ts) when the engine can do it exactly; input/CompressedJSON.ts, whose CompressedJSONFromString.parseSync lets the engine read a JSON sample before parsing it itself (see JSON samples), and decodes a sample given as bytes; and input/Inputs.ts, whose jsonInputForTargetLanguage is typed to take such samples (see JSON samples as bytes), and whose JSONInput reads the samples of a source with jsonLines with src/native/lines.ts (see JSON Lines). Everything else before the run stays in TypeScript, so inputs are collected, schema text parsed (JSON, then YAML) and files and URLs read exactly as before. Each run is one call into crates/quicktype-wasm, carrying the JSON inputs (the engine's own copy of their samples, or their CompressedJSON tables) and normalized JSON Schema sources; the engine fetches $refed schemas through the input's own JSONSchemaStore while it builds types, at the points where TypeScript awaits them. Errors come back as quicktype's message kinds and are rebuilt with the TypeScript messageError, so QuickTypeError's messageName, message and properties are the same; JavaScript exceptions are rethrown as the same class with the same message; whatever a store or onTiming throws is rethrown as is.

Runs the engine does not model use the original TypeScript engine, with the same results by construction (quicktype's, so without the bug fixes of the engine):

  • a custom TargetLanguage (any subclass or modified instance), or a CompressedJSON, Input or date/time recognizer that is not quicktype's;
  • JSONSchemaInputs with extra attribute producers;
  • option values outside what quicktype's options read (a number for a string option, "toString" for an enum option, a Name in leadingComments, …);
  • GraphQL input (quicktype-graphql-input: the Rust port of it is not part of the engine yet);
  • a language whose renderer the engine does not have (every built-in language has one): the engine says so (supportsLanguage, and an { unsupported } outcome should a run hit a missing feature midway), never with an error;
  • strings that are not well-formed UTF-16 (lone surrogates, which JSON.parse accepts), anywhere in the run, and store documents with them, circular ones or ones too large to flatten.

If the engine fails (traps, or overflows the stack), every run in flight on that instance is redone on the TypeScript engine and the instance is replaced. Before a run is redone, its JSON Schema inputs are put back as they were. An engine that has as many runs in flight, or holds as many inputs, as its tables take (2^21 each) has not failed: that run, or that input's samples, go to the TypeScript engine, and the instance stays.

QUICKTYPE_ENGINE=ts (or globalThis[Symbol.for("quicktype-core.engine")] = "ts") runs everything on the TypeScript engine; wasm makes a failure to load the engine an error instead of a fallback. engineStats in dist/native/bridge.js counts the runs on each engine (wasm, ts) and the runs the engine declined (unsupported, by feature in unsupportedBy) or that were redone after it failed (rerun), the JSON samples the engine read (samplesRead), the CompressedJSONs whose TypeScript tables were filled after all (tablesFilled), the compressed forms the engine exported and let go of to stay within its memory limit (evicted; see JSON samples), and those it freed without exporting them because nothing could reach them any more (dropped).

The engine needs crypto.getRandomValues (the Web Crypto API). It seeds its hash maps with it when it starts, because their keys come from the input and WebAssembly has no randomness of its own. Every host the package supports has it: Node 20 and later, browsers and workers. Where it is missing, the engine does not load. engineLoadError() in dist/native/engine.js is then an Error that says "quickertype needs crypto.getRandomValues (the Web Crypto API) to seed its hash maps, and this JavaScript host does not have it", and every run uses the TypeScript engine. With QUICKTYPE_ENGINE=wasm, runs throw that error instead. If crypto.getRandomValues exists but throws, the error says what it threw.

JSON samples

JSONInput.addSource and addSourceSync parse every sample on the spot (CompressedJSONFromString.parseSync: JSON.parse, then process the value into the CompressedJSON's tables), and a run then reads those tables. Here the engine reads the sample instead, when it can, and keeps the result for the runs: parsing in TypeScript and converting the tables for every run are both skipped.

Design. parseSync first asks src/native/samples.ts. For a CompressedJSONFromString that is exactly quicktype's (its prototype and own fields; the methods its class had when the package loaded, none replaced on the instance or on a prototype, since the engine's read stands in for all of them; a built-in date/time recognizer, an instance of its class without own properties whose methods are still the ones that class had then; a valid integer range: all checked at its first sample; for the later ones, that its prototype, the number of its own properties, its methods and its configuration are unchanged) and a string sample that is well-formed UTF-16 (or a sample given as bytes), while the engine is compiled (see below) and not forced off, that is one engine call per sample: jsonRead(id, text) (jsonReadBytes(id, bytes) for bytes, which reads them as UTF-8 after a leading byte order mark, and leaves bytes that are not UTF-8 to the facade, which decodes them as TextDecoder does and calls jsonRead) reads the text with the port's JSON.parse-semantics reader (CompressedJson::read_string_sample in quicktype-core: V8's grammar, own-property order, the last of duplicate keys) into a compressed form held in WebAssembly memory, one per CompressedJSON (id, made by jsonCreate with the first sample), and returns the sample's root Value. parseSync returns it, and JSONInput stores it in _topLevels as it would its own. The CompressedJSON's four table fields (_strings, _stringIndexes, _objects, _arrays) stay empty and become accessors: the first read or write of any of them fills all four with the engine's tables (materialize: jsonExport, one conversion, no parsing), which are the ones TypeScript builds from the same samples, and from then on the CompressedJSON is an ordinary one whose samples TypeScript reads. A run on the engine sends a lease on the compressed form instead of the tables (kind: "jsonShared"); a run on the TypeScript engine reads the tables, which fills them.

JSON Lines. The samples of a source with jsonLines are read by src/native/lines.ts, which asks the same reader first: jsonReadLines(id, text) (jsonReadLinesBytes(id, bytes) for bytes) reads the text with CompressedJson::read_string_lines_sample into the same compressed form, as the array of its values, exactly as the JSON text of that array would be read, and returns the array's root Value. Everything here holds for it as for a JSON sample, but for bytes that are not UTF-8, which the engine leaves to the JSON Lines reader (nothing is decoded whole). What the engine does not read, the JSON Lines reader reads: scanJSONLines finds where each value ends (after its closing bracket or quote, or at the whitespace after a number or a literal; one scanner for strings and one for bytes, each specialized), and each value is parsed with JSON.parse (the bytes of each decoded by themselves, which gives the text decoding them all would) and handed to process as soon as it is parsed, inside one array context (pushArrayContext, then finishArray and finish: what process of the array does). Should a line fail, what the values before it added to the tables and the context is taken back. A sample that is not JSON Lines is not read by the engine (it reports so, without changing anything); the JSON Lines reader then only looks for the bad line, without touching the tables, and throws its error, so the error is the same on both engines.

When the engine reads samples. Only once it is compiled: in browsers the module compiles in the background from the start, and samples added before that are read by TypeScript; in Node, where compiling is synchronous, the first run that uses the engine compiles it, and so does a sample of at least 1 Mi code units (reading a sample that large on the engine saves more than compiling costs, some 20 ms of CPU). A smaller sample never compiles it: if the run goes to the TypeScript engine (a custom language, say), compiling would be wasted.

The engine leaves a sample to TypeScript (after filling the tables, so that TypeScript continues from the state it would have) when it cannot return what TypeScript would: a root value that is a string (its Value is an index into TypeScript's string table, which the engine's does not mirror), nesting deeper than 256 levels (TypeScript's recursive process runs out of stack at a few thousand levels, earlier on a smaller or fuller stack; such a sample keeps whatever TypeScript does with it), a \u escape that leaves a surrogate unpaired (a Rust string cannot hold it), a configuration (dateTimeRecognizer, handleRefs, supportedIntegerRange) that changed since the first sample, a compressed form that a run holds, an engine instance that failed, and an engine that holds as many inputs as it takes. A sample that is not JSON is not read at all: the engine reports that it is not JSON, without changing anything, and parseSync goes on to JSON.parse, which throws.

Lifetime. The compressed form lives as long as its CompressedJSON does, so that any number of runs can use it: a FinalizationRegistry on the CompressedJSON frees it once the input is collected (a run that never happens costs nothing beyond that), and filling the tables frees it at once. A run takes its own reference (an Rc, the lease, jsonAcquire) when it is encoded, synchronously, before it waits for the engine, and keeps it until it ends: it keeps the samples it was encoded with even if the CompressedJSON is collected or its tables filled before it starts (a run on the TypeScript engine in between, say), or evicted (see below). A run that does not start on that instance lets go of its leases. Ids of runs, compressed forms and leases are never reused: each carries its slot's generation, so an id that outlived its value finds nothing, never another input's samples (crates/quicktype-wasm/src/slots.rs). Runs at once on the same input share the compressed form. A sample added while a run holds it is left to TypeScript (the engine never changes a compressed form a run is reading). The texts of the samples are not kept, except while an input's add up to at most 4 Mi code units: if an instance fails, those are read again by TypeScript the next time anything needs the tables, and a larger input's tables are taken from the failed instance's memory, which a panic, running out of memory or a stack overflow leaves readable (should even that fail, every use of the tables throws). No read holds the engine's table of inputs while it reads, so an instance that runs out of memory in the middle of a sample still has every other input's tables; the input it was reading has only its kept samples. A run whose samples were read by another instance than the one it would run on goes to the TypeScript engine. Hosts without FinalizationRegistry read every sample with TypeScript.

Memory. The garbage collector does not see the engine's memory, and WebAssembly memory never shrinks, so a long-running process cannot count on its inputs being collected before the engine runs out of its 4 GiB. The compressed forms in an instance are therefore kept within 256 MiB together, as the engine counts them (the capacities of their tables, and the tallies a run kept with them, below; jsonHeld), all but the one a sample was just read into or a run just used, which stays however large. After a sample is read or a run ends, if the others are past that limit, they are kept most recently used (read into, or leased by a run) first, each one as long as it still fits beside those kept before it, and the rest are evicted. So a form past the limit on its own (a large input read in many samples) evicts none of the smaller ones while it is read into, and is the one evicted once another input is read. An evicted form's tables are exported to JavaScript, where the garbage collector sees them, and the form is freed in the engine: the input's CompressedJSON gets those tables when anything first uses it, and from then on it is an ordinary CompressedJSON, whose further samples TypeScript reads and whose runs send its tables. A form whose CompressedJSON the garbage collector has collected already, though its finalizer has not run yet (its WeakRef no longer dereferences), is not exported but dropped, first: nothing can reach it. One that is gone but not collected yet cannot be told from one in use (a WeakRef also keeps its target alive until the job that made or read it ends, which in a loop of awaits is the whole loop), so its tables are exported, and collected with it. A run that holds an evicted form keeps it until it ends. The limit is the form of about 190 MB of JSON (a 104 MB sample takes 138 MiB), more than nearly any program has in its inputs at once, so that eviction is a backstop for inputs the garbage collector has not got to, not something runs normally pay for (an evicted input's runs send its tables, which costs what reading its samples on the engine saved). It leaves most of the 4 GiB to reading samples and to runs, which need more than the forms they make or use while they last (reading that sample peaks at 461 MiB with its form; a run on it needs 114 MiB besides); since the memory never shrinks, the engine of a long-running process stays at about the limit plus the largest of those. (With every input kept and a 16 MiB limit, 200 inputs of a 1 MB sample leave the engine at 54.6 MiB of memory, as after the first 50; without a limit it grew by 2.2 MiB per input, to 539 MiB.)

A long-running program that makes many large inputs one after the other can therefore pay for eviction until the garbage collector has collected the old ones: their forms still count toward the limit, and their tables are copied out when the next input is read. That is expected, and it only matters for inputs whose forms come near the limit on their own. In Chrome, the form of a 450 MB sample takes 230–250 ms to evict, and that of a 656 MB sample about 340 ms. In a benchmark loop that read one 450 MB input per round, 7 of 8 were evicted while an old input was still reachable from the loop's own frame (the previous round's variables), even with gc() between rounds. With each round in a function of its own and gc() after a task boundary, all 7 were dropped instead, and reading took 2,212 instead of 2,482 ms. The playground's workers avoid eviction altogether with releaseJSONInput(input) in dist/native/samples.js, which frees the form of an input they will not use again right away. That function is not part of the public API: the input must not be used afterwards, and using it throws.

The playground also reads a large file (a JSON array or JSON Lines of 16 MiB or more) in parts, on several engine instances in Web Workers of their own, with readJSONInputInParts in dist/native/parallel.js, which is not part of the public API either. The input then holds the sample as addSource would have added it, giving every run what reading it in one go gives, but the engine keeps tallies of it rather than its compressed form; should anything read its CompressedJSON's tables, they are filled by reading the sample again with TypeScript, so they are what TypeScript would have built, or, if that fails, the input is left as it was and the error says the tables cannot be had, as every later use of them does at once, without reading the sample again (see the repository's docs/STREAMING-INFERENCE.md, "In the browser").

Why this cannot be told apart from TypeScript reading the samples:

  • Errors surface where they did. addSource/addSourceSync still call parseSync for each sample at the same point; only the engine's answer differs. A sample that is not JSON reaches V8's JSON.parse, so the error is V8's own, thrown from addSource as before, after the same earlier samples were added to the tables. The engine's reader accepts exactly V8's grammar (a port of json-parser.cc; checked against the 5,017 recorded JSON.parse vectors and seeded random documents and mutations); should it ever reject a text V8 accepts, V8 parses it and TypeScript continues (the tables are filled first). Samples that are not strings, and every sample of other CompressedJSONs, take TypeScript's path untouched.
  • The same Values. A root Value is tag | index << 4. The engine returns it only for roots whose index does not depend on the string table: null, booleans, numbers (classified as parsedNumberIsDouble does, from the same f64 and range), strings over 64 code units, and objects and arrays, which it numbers in the order they end, as process interns them, counting every sample read into the same CompressedJSON. So _topLevels holds the very numbers TypeScript would put there.
  • The same tables, whenever they are looked at. The tables only change when a sample is read, and only through these four fields, so any code that could observe them (TypeScript's inference, hashCode, getStringForValue, a user's CompressedJSON shared by inputs, JSON.stringify, reading the private fields) goes through the accessors first. The engine's tables are TypeScript's for the same samples: it interns strings where process does (a value's strings, then its key, as commitValue interns currentKey; only the members JSON.parse keeps, so one "__proto__" of two; a new index for every "__proto__"; a string format's kind name; nothing of a sample that is not JSON or that it declines), numbers objects and arrays in the order they end, and encodes values as makeValue does (CompressedJson::encode_value). The fill starts from the empty tables the CompressedJSON had (the engine only starts on a fresh one), adds the strings as internString does (the same _stringIndexes, in the same property order), and leaves out a sample the engine read and then declined (a string root); the arrays and the object are the originals. The other fields a read creates (_ctx, _rootValue) are created by the engine's reads as process would create them, in the same order. What remains observable is that Object.getOwnPropertyDescriptor shows the four fields as accessors until they are first used. (After an engine failure, a small input's samples are read again by TypeScript's own process, with the configuration each was read with and any read in progress set aside, which gives the same tables.)
  • The same timing. parseSync stays synchronous and parse still awaits it once, so addSource settles after the same number of microtask ticks, and concurrent addSource calls on one input interleave their samples the same way.
  • The same runs. A run on the engine builds the same compressed form from the shared samples that it would build from the tables (the tables are its encoding), with the _topLevels read when the run starts, as before. Either way it infers the types from tallies of that form, made in one walk over it when the run starts, which give the types quicktype infers from its values (docs/STREAMING-INFERENCE.md, "Tallies of a compressed form"). The engine keeps those tallies with the form, so that the next run over the same samples (the same input, another language or other options) skips the walk, until a sample is read into the form; they count in the form's bytes, and evicting the form drops them. Reading samples prints nothing and reports no timing in TypeScript, nor here; a run's read input timing covers inference in both. quicktypeMultiFileSync uses the shared samples like quicktype(); where the engine is not compiled yet, samples are read by TypeScript in the first place.
  • Everything else is TypeScript. Whenever the engine does not take a sample (see above), or the TypeScript engine runs, the tables are filled first and TypeScript's code runs on the state it would have.

Loading

The engine is one .wasm file, dist/native/wasm/quicktype_wasm_bg.wasm (4.9 MiB, 1.8 MiB gzipped), shared by the CommonJS (dist/) and ES module (dist/esm/) builds.

  • Node: nothing happens at import. The first run reads and compiles the file synchronously, so quicktypeMultiFileSync works from the start. A JSON sample added before that compiles it only if it has at least 1 Mi code units; smaller ones are read by TypeScript (see JSON samples).

  • Browsers: the ES module build starts WebAssembly.compileStreaming at import, from new URL("../../../native/wasm/quicktype_wasm_bg.wasm", import.meta.url), which bundlers with asset support (Vite, webpack 5, Parcel) emit as an asset. quicktype() waits for it; quicktypeMultiFileSync uses the engine once it is ready and the TypeScript engine until then, and JSON samples added before it is ready are read by TypeScript. With the TypeScript engine forced ("ts", set before the import), nothing is fetched or compiled; should the mode change later, the first run that may use the engine loads it.

  • Bundlers without asset support (esbuild, an iife bundle): set globalThis[Symbol.for("quicktype-core.wasmModule")] to a WebAssembly.Module (or the file's bytes) before the first run:

    const response = await fetch("/quicktype_wasm_bg.wasm");
    globalThis[Symbol.for("quicktype-core.wasmModule")] =
        await WebAssembly.compileStreaming(response);

If the engine cannot be loaded (the file cannot be fetched, the module does not compile, or it does not instantiate as this engine), every run uses the TypeScript engine. Loading is not tried again on each run, unless a different module is supplied.

The module uses the WebAssembly features Rust's wasm32-unknown-unknown target enables by default (bulk memory, multi-value, mutable globals, non-trapping float-to-int conversions, reference types and sign extension), so the engine runs in Chrome and Edge 96, Firefox 79 and Safari 15 and later, and in every Node this package supports (20 and later). Where the module does not compile, everything runs on the TypeScript engine, as above.

Building and testing

Needs Rust (with the wasm32-unknown-unknown target), wasm-bindgen-cli in the version of the wasm-bindgen crate (cargo install wasm-bindgen-cli --version 0.2.114 --locked) and Node 20+.

npm install
npm run build                  # cargo build (release, wasm32) + wasm-bindgen + wasm-opt -O3 + tsc (CJS and ESM)
npm test                       # builds the tests' engine (script/test-hooks.mjs), then package checks, engine tests (pow vectors, concurrency, traps, samples)
node --expose-gc test/bench/compare.mjs [--browser] [--cold N]   # WebAssembly against TypeScript
npm run test:differential      # same API calls against the reference quicktype-core and this package
npm run test:browser           # headless Chrome: bundled with esbuild, run in a page
npm run check:upstream         # src/ is still upstream's (needs a quicktype checkout)

wasm-opt is binaryen's, pinned in devDependencies (--no-wasm-opt skips it). The tests that trap an instance or read the engine's counters use their own engine, built with quicktype-wasm's test-hooks feature into build/test-hooks/ (node script/test-hooks.mjs, which npm test runs after npm run build); the shipped engine has none of those exports. The engine's global allocator is Rust's own (dlmalloc) growing the WebAssembly memory geometrically (crates/quicktype-wasm/src/allocator.rs): growing it a page at a time made runs with outputs of millions of lines superlinear. Neither changes what a run computes.

The differential suite (test/differential/) compares results (every file, line and annotation), errors and console output of: the golden corpus replayed through the API, every input × every language with default options, ports of quicktype's API-level unit tests, JSON Schema store paths (lazy fetch order, failures, concurrency, re-entrancy), errors and options, and JSON samples as the engine reads them (errors from addSource, the inputs' private state, key order, numbers, deep nesting, repeated and concurrent use; category samples). The reference is the built packages/quicktype-core of a quicktype checkout ($QUICKTYPE_REFERENCE, or ../quicktype / ../../quicktype next to the repository), else this package's own TypeScript engine. Identical results are reported by where they ran: on WebAssembly, on the TypeScript fallback (declined by the engine as unsupported), or on TypeScript because the run was not eligible.