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

tigerspec

v2026.9.17

Published

A runtime validation and assertion library.

Downloads

211

Readme

spec.js

A runtime validation and assertion library.

Define executable specifications from types, shapes, and predicates. The library validates without coercion or transformation; it does not provide schema serialization, compilation, masking, or timeouts.

Why

Executable schema reference: Document data shapes, pinpoint breaking changes, and catch unexpected or missing values early.

System invariant checks: Use runtime assertions to stop when program state violates a contract.

Inspired by Clojure Spec and TigerStyle.

Quick Start

import { spec, t } from './spec.js';

// Define a schema using composable validators
const configSchema = spec({
  server: {
    host: t.string,
    port: t.number.min(1).max(65535)
  },
  database: t.optional({
    urls: [t.string],          // Repeating array
    retries: t.number.and(n => n >= 0)
  })
});

// 1. INSPECTION (diff)
const badData = { server: { host: 'localhost', port: '8080' } }; // port is string!
const mismatch = configSchema.diff(badData);

if (mismatch) {
  console.log(mismatch.displayPath); // ".server.port"
  console.log(mismatch.kind);        // "type"
}

// 2. ENFORCEMENT (assert)
const validData = { server: { host: 'localhost', port: 8080 } };
const config = configSchema.assert(validData); // Returns data safely

Edge runtimes and serverless environments.

spec.js is incidentally also a good fit for cloud functions.

  • Low bundle size
  • Fast startup (no compilation to native code)
  • Fail fast - halts on first error

Non-goals

  • Coercion
    • No defaults, not transformations.
  • FE client validation
    • Returns the first error only, not all errors, ergo not suitable for browser-autofill multi-validation.
    • Doesn't include a plethora of validation utils.
  • Server-side request validation -
    • Performance: Specs are thunks, not compiled ahead of time. Technically not the fastest way possible, but practically fast enough for most use cases.
    • Security: It's up to you to defend against ReDOS (regex denial of service), remember to check .max() lengths, and to configure your proxy/load balancer to reject oversized requests.
    • Privacy: No masking.

Documentation

To get to know spec.js completely, check out the guides below:

  • Step-by-Step Walkthrough — A comprehensive introduction to all APIs, safety behaviors, and quirks.
  • Background & Philosophy — The rationale, Clojure's Spec/TigerStyle inspirations, and the design behind the project.
  • Design Decisions — Architectural tradeoffs, uncompiled closures (thunks), and open validation.
  • Idea Bucket — Scratchpad of ideas, possible upcoming features, and what is intentionally left out of the library.

Installation

Copy spec.js into your project to use this repository's current version, or install the published tigerspec package. Published releases may lag this repository.

Maintainer release instructions are in npm/README.md.