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.1.0

Published

A TypeScript implementation of Simhash algorithm for near-duplicate detection

Downloads

139

Readme

simhash-ts

A TypeScript implementation of SimHash variants for near-duplicate detection and exact-match workflows.

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.

simhashEquality(text, params?)

  • Equality-oriented profile designed for exact tag matching.
  • Uses aggressive canonicalization + stemming + stopword filtering, then bucketed min-hash style sketching.
  • Best when your query system can only do exact hash equality and not distance thresholds.

Equality profile note

  • Current default profile is simhash-equality-v2.
  • Default parameters: shingleSize=1, bucketCount=2, keptHexCharsPerBucket=3, minTokenLength=4.
  • 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.