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

lawspec

v0.18.0

Published

State the law once. Check it everywhere.

Readme

LawSpec

State the law once. Check it everywhere.

LawSpec is a specification language for the laws your code must obey. It compiles reusable laws and concrete examples into native property-based tests and implementation adapters for Java, Python, JavaScript, TypeScript, Go, Haskell, Kotlin and Rust. The compiler is written in Haskell and distributed on npm as prebuilt WebAssembly, with a Node CLI and a typed JavaScript API.

Features

Install

Node 22+ and the selected target's build tools are required. No Haskell toolchain is needed. The reference platforms are macOS and Linux.

npm install --save-dev [email protected]
npx lawspec --version

To try it in a new, empty directory, initialize before installing, so that LawSpec can create package.json and its test script:

mkdir lawspec-example
cd lawspec-example
npm exec [email protected] -- lawspec init --target javascript
npm install --save-dev [email protected]
npx lawspec check
npx lawspec explain 'example.atoi_codec::itoa and then atoi yields a'
npx lawspec doctor
npx lawspec generate

Implement src/example/atoi_codec.mjs, then run npm test:

export function itoa(value) { return String(value); }
export function atoi(value) { return Number(value); }

In an existing project, install LawSpec first, then run npx lawspec init --target javascript. Existing build files are preserved; apply the printed setup instructions before generating. See Install LawSpec and create a project.

Example

unit example.atoi_codec

itoa :: Int32 -> Text
atoi :: Text -> Int32

law `round trip` is
  definition is
    `left inverse` atoi itoa
  end
  description is
    "applying {itoa} and then {atoi} recovers the original integer"
  end
  example `negative integers use a minus sign and round-trip unchanged` is
    x = -42
    expect itoa x = "-42"
    expect atoi (itoa x) = -42
  end
end

lawspec explain shows the final property:

for all (x :: Int32) . atoi (itoa (x)) = x

The generated tests check the example, signed 32-bit boundary cases and randomized inputs against your itoa and atoi, on whichever targets you configure.

Targets

| Target | Build setup | Test libraries | Test command | | --- | --- | --- | --- | | java | Maven, JDK 25, release 25 | JetCheck 0.3.0, JUnit Jupiter 5.14.x | mvn test | | python | Python 3.13 or 3.14, pyproject | pytest 8.4.x, Hypothesis 6.135.26+ (6.x) | python -m pytest | | javascript | Node 22+, npm, ESM | fast-check 4.x, node:test | npm test | | typescript | Node 22+, npm, TypeScript 5.9.x, ESM | fast-check 4.x, node:test | npm test | | go | Go modules, Go 1.22–1.26 | Rapid 1.2.0, testing | go test ./... | | haskell | Stack, GHC 9.10, LTS 24.58 | Hspec 2.11, Hedgehog 1.5, hspec-hedgehog 0.3 | stack test | | kotlin | JDK/JVM 25, Gradle 9.1–9.3, Kotlin 2.3.21 | Kotest 5.9.1 | gradle test | | rust | Rust 1.85+, edition 2024, Cargo | Proptest 1.11.0 | cargo test |

See the target guides.

Documentation

The documentation has tutorials, how-to guides, a reference for the language, CLI, configuration and API, and explanations of the design. Release history is in the changelog. To work on LawSpec itself, see contributing.

Syntax highlighting is available as a VS Code extension.

License

MIT. See LICENSE.