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

fuzzify

v0.1.1

Published

A lightweight fuzzy search library

Readme

fuzzify

A tiny lightweight library for Fuzzy Search.

Why

I made this library as a result of learning about Levenshtein Distance algorithm to calculate the minimum number of single-character edits (insertions, deletions or substitutions) required to transform one word to another by Vladimir Levenshtein.

[!NOTE]
Note: The library is at a very early stage so if you want to To help improve it, please open an issue.

Live Demo

You can check the demo here.

Installation

with yarn

yarn add fuzzify

with npm

npm install fuzzify

Usage

import Fuzzy from "fuzzify";

const countries = [
  "Australia",
  "France",
  "Germany",
  "Hungary",
  "Iceland",
  "India",
  "Israel",
  "Italy",
  "Japan",
  "Malawi",
  "Malaysia",
  "Maldives",
];
const fuzzy = new Fuzzy(countries);

const query = "ala";
const results = fuzzy.search(query);

console.log("RESULTS", results);

The search API gives approximate matched strings with the passed query in the below format.

| Attributes | Description | | ---------- | ------------------------------------------------------------------------------------------------------------------ | | text | The target string against which the query is matched | | distance | The minimum number of edits (Insertion / Deletion / Substitutions) required to transform the query to target text. |

[
  {
    text: "Malawi",
    distance: 3,
  },
  {
    text: "Malaysia",
    distance: 5,
  },
  {
    text: "Australia",
    distance: 6,
  },
  {
    text: "Italy",
    distance: 3,
  },
  {
    text: "Japan",
    distance: 3,
  },
  {
    text: "Iceland",
    distance: 5,
  },
  {
    text: "Maldives",
    distance: 6,
  },
  {
    text: "Israel",
    distance: 5,
  },
  {
    text: "India",
    distance: 4,
  },
  {
    text: "France",
    distance: 5,
  },
  {
    text: "Germany",
    distance: 6,
  },
  {
    text: "Hungary",
    distance: 6,
  },
];

Options

includeMatches

includeMatches - Determines whether the indices at which characters match should be returned in the response. Each match element consists of two indices -

  1. The index of query string where match is found.
  2. The index of target string where a match is found.

Example :point_down:

query = "ala", target string = "Australia"
matches: [
  [0, 5],
  [1, 6],
  [2, 8],
],

In the above example :point_down: matches are found

  1. character a at 0th index in ala matches with characater a at 5th index in Australia
  2. character l at 1st index in ala matches with characater a at 6th index in Australia
  3. character a at 2nd index in ala matches with characater a at 8th index in Australia

The complete response would be :point_down:

[
  {
    text: "Malawi",
    distance: 3,
    matches: [
      [0, 1],
      [1, 2],
      [2, 3],
    ],
  },
  {
    text: "Malaysia",
    distance: 5,
    matches: [
      [0, 1],
      [1, 2],
      [2, 7],
    ],
  },
  {
    text: "Australia",
    distance: 6,
    matches: [
      [0, 5],
      [1, 6],
      [2, 8],
    ],
  },
  {
    text: "Italy",
    distance: 3,
    matches: [
      [0, 2],
      [1, 3],
    ],
  },
  {
    text: "Japan",
    distance: 3,
    matches: [
      [0, 1],
      [2, 3],
    ],
  },
  {
    text: "Iceland",
    distance: 5,
    matches: [
      [1, 3],
      [2, 4],
    ],
  },
  {
    text: "Maldives",
    distance: 6,
    matches: [
      [0, 1],
      [1, 2],
    ],
  },
  {
    text: "Israel",
    distance: 5,
    matches: [
      [0, 3],
      [1, 5],
    ],
  },
  {
    text: "India",
    distance: 4,
    matches: [[2, 4]],
  },
  {
    text: "France",
    distance: 5,
    matches: [[2, 2]],
  },
  {
    text: "Germany",
    distance: 6,
    matches: [[2, 4]],
  },
  {
    text: "Hungary",
    distance: 6,
    matches: [[2, 4]],
  },
];

includeScore

Determines whether a score should be added in the result. A score of 1 means an exact match, however a score of 0 means no match and those options are removed from the result. If you want to get all the options in the result, please open an issue and let's discuss.

caseSensitive

Determines whether the query should be case-sensitive or not. By default, this option is false.

Set up

Install packages:

yarn

Start development playground:

yarn start

Build command:

yarn build

Contributing

Please open an issue so we can start discussing. Any help to improve the library is most welcome :).