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 🙏

© 2024 – Pkg Stats / Ryan Hefner

libnpmdiff

v7.0.0

Published

The registry diff

Downloads

2,454,054

Readme

libnpmdiff

npm version license CI - libnpmdiff The registry diff lib.

Table of Contents

Example

const libdiff = require('libnpmdiff')

const patch = await libdiff([
  '[email protected]',
  '[email protected]'
])
console.log(
  patch
)

Returns:

diff --git a/package.json b/package.json
index v1.1.0..v1.1.1 100644
--- a/package.json	
+++ b/package.json	
@@ -1,6 +1,6 @@
 {
   "name": "abbrev",
-  "version": "1.1.0",
+  "version": "1.1.1",
   "description": "Like ruby's abbrev module, but in js",
   "author": "Isaac Z. Schlueter <[email protected]>",
   "main": "abbrev.js",

Install

$ npm install libnpmdiff

Contributing

The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide outlines the process for community interaction and contribution. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow the npm Code of Conduct, and just generally be excellent to each other.

Please refer to the Changelog for project history details, too.

Happy hacking!

API

> libnpmdif([ a, b ], [opts]) -> Promise<String>

Fetches the registry tarballs and compare files between a spec a and spec b. npm spec types are usually described in <pkg-name>@<version> form but multiple other types are alsos supported, for more info on valid specs take a look at npm-package-arg.

Options:

  • color <Boolean>: Should add ANSI colors to string output? Defaults to false.
  • tagVersionPrefix <Sring>: What prefix should be used to define version numbers. Defaults to v
  • diffUnified <Number>: How many lines of code to print before/after each diff. Defaults to 3.
  • diffFiles <Array<String>>: If set only prints patches for the files listed in this array (also accepts globs). Defaults to undefined.
  • diffIgnoreAllSpace <Boolean>: Whether or not should ignore changes in whitespace (very useful to avoid indentation changes extra diff lines). Defaults to false.
  • diffNameOnly <Boolean>: Prints only file names and no patch diffs. Defaults to false.
  • diffNoPrefix <Boolean>: If true then skips printing any prefixes in filenames. Defaults to false.
  • diffSrcPrefix <String>: Prefix to be used in the filenames from a. Defaults to a/.
  • diffDstPrefix <String>: Prefix to be used in the filenames from b. Defaults to b/.
  • diffText <Boolean>: Should treat all files as text and try to print diff for binary files. Defaults to false.
  • ...cache, registry, where and other common options accepted by pacote

Returns a Promise that fullfils with a String containing the resulting patch diffs.

Throws an error if either a or b are missing or if trying to diff more than two specs.

LICENSE

ISC