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

@ossl-dev/differens-git

v0.2.0

Published

Git integration for differens: working tree, commit range and directory diffs, and the diff driver

Readme

@ossl-dev/differens-git

Reads file pairs out of git for differens to diff, and registers differens as a git diff driver.

npm install @ossl-dev/differens-git

Shells out to the git binary. No native bindings, nothing to compile.

Getting pairs to diff

import { diffWorkingTree, diffCommitRange, diffDirectories } from "@ossl-dev/differens-git";

await diffWorkingTree();                 // working tree vs HEAD
await diffCommitRange("main..feature");  // every file changed in a range
await diffDirectories("old/", "new/");   // two trees on disk, no git needed

All three return the same shape, ready to hand to a diff:

interface GitDiffInput {
  oldPath: string;
  newPath: string;
  oldSource: string;
  newSource: string;
}

A file that exists on only one side comes back paired against "", which downstream reports as a whole-file add or removal rather than as a hundred inserted lines.

Blobs are read through a single git cat-file --batch process. A 200-file changeset used to pay 400 process spawns before any diffing started, which on a warm cache cost more than the diff. Every blob is read in full: large files (generated bundles, lockfiles) diff for real instead of being skipped.

The diff driver

import { installGitDriver, diffDriverCommand, DRIVER_FLAG, generateGitAttributes } from "@ossl-dev/differens-git";

await installGitDriver(diffDriverCommand(process.execPath, [entryPath, DRIVER_FLAG]));

That registers diff.differens.command. Add the matching .gitattributes lines from generateGitAttributes(["ts", "tsx", "py"]) and git diff narrates those files instead of printing hunks.

Git invokes a driver with path old-file old-hex old-mode new-file new-hex new-mode, where the two files are temporaries of its own naming. Pick your parser from path, not from the temp name -- the temp name has no extension, and classifying by it line-diffs every file the driver was registered for.

This is a command driver, not a textconv one. Textconv converts a single file to text and lets git line-diff the results, and there is no single-file rendering of a source file that makes a semantic diff fall out of that.

Also exported

isGitRepo(), resolveRef(ref), getChangedFiles(), getHeadContent(path), getWorkingTreeContent(path), readFilePair(a, b), isDirectory(path).

resolveRef returns null rather than throwing for anything that is not a ref, which is how differens a.ts b.ts and differens main feature are told apart from the same two arguments.

Related

MIT. Source.