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

fuzzy-vir

v0.0.2

Published

Fuzzy string matching via MinHash + LSH with O(1) lookup, designed for streaming use.

Downloads

2,105

Readme

fuzzy-vir

Easy-to-use utilities for fuzzy matching.

Install

npm i fuzzy-vir

Usage

FuzzyIndex

Groups near-duplicate strings under a shared cluster key with O(1) lookup. Use it to dedupe or count things like error messages that differ only in embedded IDs, timestamps, or line numbers.

import {FuzzyIndex} from 'fuzzy-vir';

/** A per-cluster counter that lives alongside the index. */
const occurrenceCounts = new Map<string, number>();

const index = new FuzzyIndex({
    /** Cap memory at 1,000 distinct clusters; older clusters are evicted FIFO. */
    maxIndexSize: 1000,
    /**
     * Keep the sidecar Map in sync with the index. Without this, entries for evicted clusters would
     * stay in `occurrenceCounts` forever, since Maps hold strong references to their keys.
     */
    onEvict(clusterKey) {
        occurrenceCounts.delete(clusterKey);
    },
});

function recordOccurrence(message: string): number {
    const key = index.insert(message);
    const next = (occurrenceCounts.get(key) ?? 0) + 1;
    occurrenceCounts.set(key, next);
    return next;
}

/** A near-duplicate (different id, same shape) collapses onto the same cluster. */
recordOccurrence('Database query failed: id abc123 not found'); // returns 1
recordOccurrence('Database query failed: id 9f0e3d not found'); // returns 2

/** A genuinely different message gets its own cluster. */
recordOccurrence('Network request timed out after 30s'); // returns 1

/** Look up without inserting; returns the existing canonical cluster key or `undefined`. */
const existing = index.findKey('Database query failed: id xyz not found');
console.info(existing); // canonical key of the "Database query failed" cluster

fuzzySearch

A one-shot fuzzy match over an array. Each item is converted to a string (via the optional itemToString), punctuation is stripped from both the query and options, and matches are scored with Fuse.js. The default threshold (0.1) keeps results close to the query. All other Fuse.js options (e.g. threshold) can be passed through to tune is also supported

import {fuzzySearch} from 'fuzzy-vir';

const fruits = [
    'banana',
    'grape',
    'apple',
    'orange',
    'pineapple',
];

/** Exact and near matches are returned, ranked by similarity. */
fuzzySearch('apple', fruits); // ['apple', 'pineapple']

/** Typos still match within the default 0.1 threshold. */
fuzzySearch('banan', fruits); // ['banana']

/** Pass `itemToString` to search over objects by a derived string. */
const people = [
    {
        firstName: 'Jane',
        lastName: 'Smith',
    },
    {
        firstName: 'John',
        lastName: 'Doe',
    },
    {
        firstName: 'Janet',
        lastName: 'Jones',
    },
];
fuzzySearch('Jane', people, {
    itemToString: (person) =>
        [
            person.firstName,
            person.lastName,
        ].join(' '),
}); // [{firstName: 'Jane', ...}, {firstName: 'Janet', ...}]

/** Loosen the threshold to allow more distant matches. Other Fuse.js options pass through too. */
fuzzySearch('aple', fruits, {
    threshold: 0.5,
}); // ['apple', 'grape', 'pineapple']