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

@mmmnt/feat-emit-ts

v0.2.1

Published

Feat emit: TestTopology + resolved schemas/goldens -> complete deterministic Vitest test file (ADR-0006 header, ADR-0001 inlining). Owns no runtime code.

Readme

@mmmnt/feat-emit-ts

The TypeScript emitter of Feature: a test topology in, one complete vitest file out. emit(inputs) takes the cases that @mmmnt/feat-derive produced, the resolved schemas and golden fixtures, and writes the text of a generated test file. The file imports only vitest, a few Node built-ins and @mmmnt/feat-runtime. It holds no logic of its own: every test calls the runtime's harness.

The output is deterministic. The same inputs give the same bytes. There is no timestamp, no random value and no machine-specific path in it, which is what lets feat verify byte-compare committed tests against a fresh generation.

Where it sits

BuiltSpec IR -> feat-derive -> TestTopology
                                   |
                        feat-emit-ts (this package)
                                   |
                  specs/foo.test.ts  (committed, generated)
                                   |
        run by vitest through feat-runner; imports feat-runtime

Most users get this package through @mmmnt/feature, whose feat generate calls emit once per spec. Depend on it directly when you build your own generator: you hold a topology and want the file Feature would write. It does not parse, does not derive and does not write to disk.

Install

npm install @mmmnt/feat-emit-ts
  • Node 20 or later. The package is ESM only.
  • Runtime dependencies are @mmmnt/feat-derive (for the TestTopology type) and @mmmnt/feat-types.
  • The package emits text. To run what it emits, the project needs vitest and @mmmnt/feat-runtime. This repository tests against vitest 3.2.

Use

This uses the spec shown in the @mmmnt/feat-derive README, saved as specs/add-item.feat, and a feat.config.json whose only service is store.

import { readFileSync } from "node:fs";
import { contextFromConfig, parseSource } from "@mmmnt/feat-core";
import { derive } from "@mmmnt/feat-derive";
import { EMITTER_VERSION, emit, timingEnvelope } from "@mmmnt/feat-emit-ts";
import type { BuiltSpec, FeatConfig } from "@mmmnt/feat-types";

const config = JSON.parse(readFileSync("feat.config.json", "utf8")) as FeatConfig;
const specText = readFileSync("specs/add-item.feat", "utf8");
const parsed = parseSource(specText, contextFromConfig(config));
if (parsed.status === "ERR") throw new Error(JSON.stringify(parsed.body));
const topology = derive(parsed.body as unknown as BuiltSpec, config);

const source = emit({
  topology,
  schemas: {},
  goldens: {},
  hashInputs: {
    specText,
    contractText: "{}",
    configSlice: { featVersion: "1.0", commands: ["AddItem"], actors: [], services: ["store"] },
  },
  specPath: "specs/add-item.feat",
  namespacePath: "specs/add-item.feat",
  configPath: "../feat.config.json",
  emitterVersion: EMITTER_VERSION,
  featVersion: "1.0",
});

console.log(source.split("\n").slice(0, 4).join("\n"));
console.log(timingEnvelope(topology.cases, { services: { store: { consistency: "eventual", convergenceTimeout: 2500 } } }));

The first four lines of source are the header. The last line prints { testTimeoutMs: 62500, hookTimeoutMs: 120000 }. In a real run schemas is the spec's resolved contract registry and contractText is the contract file's text.

The generated file

In order:

  1. Header. Four comment lines:

    // AUTO-GENERATED by feat emit — do not edit manually
    // Source: specs/add-item.feat (SPEC-ITM-002)
    // Language: feat 1.0 · Emitter: @mmmnt/[email protected]
    // Inputs-hash: sha256:<64 hex digits>
  2. Imports. describe, it, beforeAll and afterAll from vitest; path and fileURLToPath; and createHarness with the Harness, HarnessCase and InlineData types from @mmmnt/feat-runtime.

  3. CONFIG_PATH. process.env.FEAT_CONFIG when set, resolved from the working directory. Otherwise configPath, resolved relative to the generated file. feat run sets FEAT_CONFIG to the active tier's config, so one file serves every tier (ADR-0024).

  4. SPEC_PATH. The namespacePath input. The harness derives the file's namespace from this string alone (SPEC-RT-006).

  5. INLINE. The schemas and golden fixtures as JSON constants. The file reads no schema or fixture at run time (ADR-0001, ADR-0013).

  6. CASES. The topology's cases as JSON, typed HarnessCase[].

  7. The suite. One describe("<specId>: <specName>"). beforeAll calls createHarness({ configPath: CONFIG_PATH, specPath: SPEC_PATH, cases: CASES }), so the response adapter is set up with the commands the cases invoke (SPEC-RT-008). Each case becomes it(c.name, ...) calling h.runCase(c, INLINE). afterAll calls h?.teardown().

The optional chain in teardown is deliberate. createHarness throws on a configuration error, and then there is no harness to tear down. Without the ?. that refusal would end in a TypeError that hides it.

Inputs-hash

The header's hash is the SHA-256 of three values joined by a NUL byte (\0):

  1. hashInputs.specText, the spec source;
  2. hashInputs.contractText, the contract file's text;
  3. hashInputs.configSlice, serialized with sorted keys at every depth, so key order never changes the hash.

Change any of the three and the hash changes. The emitter version is in the header but not in the hash. The hash fingerprints the inputs, not the output: the topology, the schemas and the goldens are not hashed. feat verify compares the whole file byte for byte, so the hash is a quick way to tell which input moved.

What goes in configSlice is the caller's choice. feat generate passes only what can change the parse or the derived structure: featVersion and the sorted names of the services, commands and actors (without default). Adapters, consistency, timeouts and options stay out, so a tier's config can change without regenerating anything (ADR-0024).

API

function emit(inputs: EmitInputs): string;

function timingEnvelope(
  cases: readonly { given?: { executes?: readonly unknown[] }; delivers?: readonly unknown[] }[],
  config: {
    services: Record<string, { consistency?: string; convergenceTimeout?: number }>;
    response?: { invoke?: Record<string, unknown> };
  },
): { testTimeoutMs: number; hookTimeoutMs: number };

const EMITTER_VERSION: string; // this package's version, read from its package.json

EmitInputs:

| Field | Meaning | | --- | --- | | topology | The TestTopology from @mmmnt/feat-derive. | | schemas | Resolved schema registry for this spec: name to JSON Schema, $refs already resolved. | | goldens | Resolved golden fixtures: spec-relative path to parsed JSON. | | hashInputs | { specText, contractText, configSlice }, the three values hashed. | | specPath | Repo-root-relative path of the .feat file, for the header. | | namespacePath | The spec file's path relative to the config directory, with / separators. It is the input of the file's namespace. | | configPath | Path to feat.config.json from the generated file's directory. feat generate passes the base config's, so the file does not depend on the tier. | | emitterVersion | Written into the header. Pass EMITTER_VERSION. | | featVersion | The language version, written into the header. |

emit does not validate its inputs. Hand it a topology from derive and schemas that match it.

timingEnvelope

The generated file carries no timeouts, because they depend on the active tier. feat run computes them from the active config with timingEnvelope and hands them to vitest as testTimeout and hookTimeout:

testTimeoutMs = invoke * steps + window + 30000
hookTimeoutMs = 120000
  • invoke is config.response.invoke.timeout when that is a number, else 30000 (ms).
  • steps is the largest, over the cases, of the given.executes count plus the greater of 1 and the delivers count. It is never below 1.
  • window is the largest convergenceTimeout among services whose consistency is eventual, else 0.

Run a generated file under plain vitest and it gets vitest's default timeouts. A scenario that waits out an eventual capture window needs feat run, or a config you write with the same numbers.

Errors

The emitter has no error codes and defines no refusals. A bad topology fails earlier, in the parser or in derive. A bad run fails in the harness, with the codes listed in @mmmnt/feat-runtime.

What changed in 0.2.1

  • The file's cases reach the harness (SPEC-RT-008). beforeAll passes cases: CASES to createHarness, so the response adapter loads what those cases invoke at setup, under the hook timeout. Needs @mmmnt/feat-runtime 0.2.2. Every generated file changes once: that line and the emitter version in its header.

What changed in 0.2.0

  • One file for every tier (ADR-0024). The file no longer bakes a timing envelope. It resolves its config from FEAT_CONFIG first. The hash covers only the spec, the contract and the closed spaces, so changing a timeout, an adapter or an option regenerates nothing. This changes the header hash of every generated file once.
  • Namespace input (SPEC-RT-006). New namespacePath input and a SPEC_PATH constant in the file. createHarness now receives specPath, and the harness derives the file's namespace from it.
  • Safe teardown. afterAll tears down only a harness that was created, so a refused createHarness no longer ends in a TypeError.
  • timingEnvelope is exported, so feat run and your own tooling share one formula.

Specs and decisions

  • SPEC-FEAT-001: the corpus exemplar for the emitter. It names src/emit.ts as its handler. The code lives in src/index.ts.
  • SPEC-RT-006: the namespace each generated file's harness derives.
  • ADR-0023: adapter interface v2.
  • ADR-0024: tier bindings and environment-agnostic generation.
  • Grammar reference: the language the topology comes from.

License

MIT

Part of Feature — the .feat execution specification language. Docs: https://github.com/mmmnt/feature/wiki