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

simhash-ts

v0.2.0

Published

TypeScript locality-sensitive hashing: Charikar SimHash plus MinHash-based equality fingerprints for near-duplicate detection and exact-match discovery

Readme

simhash-ts

A TypeScript toolkit of locality-sensitive hashing algorithms for near-duplicate detection and exact-match workflows.

Two different algorithm families live here. simhash / simhashHardened are Charikar SimHash (sign-of-random-projections, compared by Hamming distance, approximates cosine similarity). minhashEquality is MinHash, not SimHash: it is b-bit one-permutation MinHash used as an exact-equality fingerprint (approximates Jaccard similarity). The package is named for the SimHash it ships, but pick the function by the algorithm you actually need.

Hashing methods

simhash(text)

  • Baseline/original implementation.
  • Uses character bigram features from raw text.
  • Best when you want a simple classic SimHash baseline.

simhashHardened(text, params?)

  • Distance-oriented profile for better robustness than baseline.
  • Adds deterministic canonicalization, mixed token/character features, TF capping, and optional window voting.
  • Best when you still care about Hamming distance behavior and nearest-neighbor style similarity.

minhashEquality(text, params?) (recommended equality fingerprint)

  • This is MinHash, not SimHash. b-bit one-permutation MinHash used as an exact-equality content fingerprint.
  • Aggressive canonicalization + stemming + stopword filtering, then a bucketed-minimum (MinHash) sketch; near-identical texts collapse to the same exact hash, discoverable by an exact tag (#X) query.
  • Wire identifier minhash-equality-v1. Default parameters: shingleSize=1, bucketCount=8, keptHexCharsPerBucket=3, minTokenLength=4.
  • Keeps the last k hex chars of each bin minimum (the b-bit minwise rule). See kb-private ADR-005 for the collision study behind the 8-bin, low-bit choice.

simhashEquality(text, params?) (legacy, frozen)

  • The original equality profile, wire identifier simhash-equality-v2. Despite the name it was already MinHash, not SimHash.
  • Frozen for backward compatibility; do not use for new content. It has a long-content false-positive defect (ADR-005); minhashEquality is its corrected successor.
  • Default parameters: bucketCount=2, keptHexCharsPerBucket=3 (kept the first k hex), minTokenLength=4.

Equality descriptor note

  • The descriptor payload includes n, b, k, and m so independent implementations can produce the same X value deterministically.

Install and run

Install dependencies

npm install

Build

npm run build

Run unit tests

npm test

Run benchmark on default corpus

npm run benchmark

Run benchmark on a custom corpus file

npm run benchmark -- path/to/corpus.json

Benchmark corpus format

The benchmark supports:

  • Legacy shape: top-level texts array
  • New shape: grouped families with expected equality pairs

Example (new shape):

{
  "topNeighbors": 6,
  "families": [
    {
      "id": "my-family",
      "description": "Optional family note",
      "expectedEqualityPairs": [
        ["text-a", "text-b"]
      ],
      "texts": [
        { "id": "text-a", "text": "..." },
        { "id": "text-b", "text": "..." },
        { "id": "text-c", "text": "..." }
      ]
    }
  ]
}

expectedEqualityPairs are used for TP/FN/FP reporting under equality-mode scoring.

Current benchmark families in benchmark/corpus.json

  • synthetic-article: regression baseline
  • real-article: populated with the provided regular-length article and variants
  • tweet-sized: short-text stress tests
  • extra-long-article: populated with your provided extra-long article and variants

Recommended corpus maintenance

  • Keep IDs stable over time so benchmark comparisons remain meaningful.
  • For each family, include at least:
    • original
    • light edit
    • padded/noisy variant
    • unrelated control
  • Update expectedEqualityPairs whenever you add or revise vectors.