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

logicdiff

v0.1.0

Published

A whitespace- and reflow-blind diff: folds respacing AND line re-wrapping that git diff -w can't, and tells you if a change is logical or just formatting. Zero dependencies.

Readme

logicdiff

A whitespace- and reflow-blind diff. A pull request reindents a file and rewraps a few long lines, and now git diff shows 80 changed lines — but did anything actually change? logicdiff answers that: it folds away pure formatting (respacing and line reflow) and shows only the logical changes.

logicdiff old.js new.js
#   only formatting differs - no logical change (a line diff would show 80 changed lines)

logicdiff a.js b.js
#   --- a.js
#   +++ b.js
#   -42:   const total = price * qty;
#   +51:   const total = price + qty;
#
#   1 token removed, 1 added across 2 logical lines (78 lines folded as reflow/whitespace)

Exit 0 when the change is formatting-only (or identical), 1 when there's a real logical change — so CI can ask "is this PR just a reformat?" Zero dependencies, language-agnostic, also on PyPI (pipx run logicdiff) — the two builds produce byte-for-byte identical output.

Why not git diff -w?

git diff -w (ignore-all-space) folds respacing — but it is still line-anchored, so it cannot fold reflow. Re-wrap a function signature across three lines and git diff -w still shows 1 removed + 3 added, even though not a single token changed. That exact gap is GitHub discussion #20610 ("Ignore Format Changes in Diff"), open and unanswered for years.

difftastic solves it beautifully with per-language tree-sitter parsing — but it's a multi-megabyte binary, needs a grammar for each language (config/log/DSL files fall back to text), and it's a display tool with no "is this formatting-only?" exit code.

logicdiff is the lightweight middle ground: zero-config, zero-dependency, language-agnostic (works on any text — code, YAML, logs, DSLs), folds both whitespace and reflow, and gives a one-shot CLI answer plus a CI exit code.

How it works

It tokenizes each file into a sequence of tokens — a token is a run of [A-Za-z0-9_] or a single punctuation character, and whitespace is dropped. So a+b, a + b, and a +\n b all become the same token stream [a, + , b]: respacing and line breaks become invisible. It then runs the canonical Myers diff on the token streams. If the streams are equal, the change is formatting-only. If not, the changed tokens are mapped back to their line numbers and shown.

Because it has no language parser, whitespace inside string literals is also ignored — x = "a b" and x = "a b" are "formatting only", exactly like git diff -w. That's a deliberate, documented limitation, not a bug.

Usage

logicdiff old new            # human diff (or "only formatting differs")
logicdiff old new --stat     # just the counts, machine-friendly key=value
logicdiff old new --json     # structured output (byte-identical both builds)
logicdiff old new -q         # no output, exit code only (the CI gate)
cat new | logicdiff old -     # - reads stdin

--color=auto|always|never, --max-tokens N (bail over N tokens, default 2,000,000). Two wildly dissimilar inputs (a huge edit distance) also bail with exit 2 instead of risking the heap — logicdiff is for spotting a real change inside a reformat, not for diffing unrelated files.

Exit codes: 0 identical or formatting-only · 1 logical changes · 2 error.

# CI: warn when a PR is more than a reformat
- run: logicdiff "$BASE" "$HEAD" -q || echo "::warning::real code change, review carefully"

Install

npm i -g logicdiff    # or npx logicdiff
pip install logicdiff # Python build, identical behaviour

Node ≥ 18 or Python ≥ 3.8. No dependencies.

License

MIT