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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@n-rowe/pash

v0.4.0

Published

A fast, minimal json patch generation library based off ohash's implementation

Readme

Pash

A fast, minimal json patch generation library based off ohash's implementation.

Motivations

The current implementation of libraries such as fast-json-patch or ohash will create additional diff entries for array elements. Which can, in some cases, defeat the simplicity of JSON Patch. To resolve this a number of changes were made on top of ohash's diff implementation:

  1. It stores the type of hashed objects.
  2. If an object is an array, it stores hashes of its direct children.
  3. If an object is an array element, do not diff properties.
    1. An array element only diffs its own hash.
    2. This means if it is an object, it will not replace individual properties.
  4. The patches generated have additional non-standard 'value' and 'from' properties for auditing.
  5. Adds support for the excludeKeys hashing option.

Usage

1. Basic usage

Below is the basic usage of pash.

import { diff } from '@n-rowe/pash'

const source = { name: 'Graham', roles: ['Admin', 'User', 'Owner'] }
const changed = { name: 'Graham', roles: ['Admin', 'Owner'] }

const patches = diff(source, changed).asPatches()
console.log(patches)
// [ { op: 'remove', path: '/roles/1', value: 'User' } ]

Compared to fast-json-patch:

import { compare } from 'fast-json-patch'

const source = { name: 'Graham', roles: ['Admin', 'User', 'Owner'] }
const changed = { name: 'Graham', roles: ['Admin', 'Owner'] }

const patches = compare(source, changed)
console.log(patches)
// [ { op: 'remove', path: '/roles/2' }, { op: 'replace', path: '/roles/1', value: 'Owner' } ]

2. Remove 1 element from large array

import { diff } from '@n-rowe/pash'
import data from './large_diff.json'

const patches = diff(data.original, data.new).asPatches()
console.log(patches)
// [ { op: 'remove', path: '/1984', value: { id: '79db2453-96c3-4bd3-8a23-1a22f77754b6', name: 'Gertrude' } } ]

Compared to fast-json-patch:

import { compare } from 'fast-json-patch'
import data from './large_diff.json'

const patches = compare(data.original, data.new)
console.log(patches)
// [ { op: 'remove', path: '/4999' }, { op: 'replace', path: '/4998/name', value: 'Kyler' } ...6029 more items ],