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

stringwise

v1.0.1

Published

Effortless and fast string similarity comparison using multiple algorithms, including bigrams, Levenshtein, Jaro-Winkler, and Ratcliff/Obershelp. Perfect for fuzzy search, NLP, and intelligent text matching.

Readme

npm version Build Status License Downloads

stringwise

stringwise is a fast and lightweight TypeScript library for comparing string similarity using multiple algorithms like bigrams, Levenshtein, Jaro-Winkler, and Ratcliff/Obershelp. It’s ideal for fuzzy searching, intelligent suggestions, and natural language processing tasks where accuracy and performance matter.

✨ Why Use stringwise?

  • ⚡️ Efficient and Lightweight: Built for real-time performance in search and suggestion engines.
  • 🧠 Multiple Algorithms: Choose from default, levenshtein, jaro-winkler, or ratcliff-obershelp.
  • 🎯 Precise Similarity Control: Use round option to control rating precision.
  • 🔍 Fuzzy Matching Made Easy: Quickly identify the best match among multiple strings.
  • 🔒 Fully Typed: Built with TypeScript for a safer developer experience.
  • 📦 Modular Structure: Ready to scale with your application needs.

📦 Installation

Install via npm or yarn:

npm install stringwise

or

yarn add stringwise

🚀 Usage

Importing

import { compareTwoStrings, findBestMatch, getSimilarityFn } from "stringwise";

Compare Two Strings

compareTwoStrings("hello", "h3llo"); // e.g. 0.5

Find Best Match

const result = findBestMatch("hello", ["halo", "hell", "hello", "world"]);

console.log(result.bestMatch);
// { target: 'hello', rating: 1 }

console.log(result.ratings);
/*
[
  { target: 'halo', rating: 0.2857142857142857 },
  { target: 'hell', rating: 0.8571428571428571 },
  { target: 'hello', rating: 1 },
  { target: 'world', rating: 0 }
]
*/

Use with Options

const result = findBestMatch("kitten", ["sitting"], {
  algorithm: "levenshtein",
  round: 3,
});

Direct Algorithm Access

const sim = getSimilarityFn("jaro-winkler");
console.log(sim("MARTHA", "MARHTA")); // ~0.9611

🧠 API

compareTwoStrings(a: string, b: string): number

Returns a similarity score between 0 and 1 using bigram overlap.


findBestMatch(main: string, targets: string[], options?: FindBestMatchOptions): FindBestMatchResult

Returns an object containing:

  • bestMatch: The string with the highest similarity
  • bestMatchIndex: Index in the original list
  • ratings: All similarity scores

Options:

type FindBestMatchOptions = {
  round?: number; // Decimal places
  algorithm?: "default" | "levenshtein" | "jaro-winkler" | "ratcliff-obershelp";
};

getSimilarityFn(algorithm: string): (a: string, b: string) => number

Returns the similarity function for a given algorithm name.


Types

type MatchRating = {
  target: string;
  rating: number;
};

type FindBestMatchResult = {
  bestMatch: MatchRating;
  bestMatchIndex: number;
  ratings: MatchRating[];
};

✅ Requirements

  • Node.js v14.0.0 or newer
  • TypeScript (recommended)

🛡 License

Licensed under the MIT License. See the LICENSE file for more details.

🤝 Contributing

Contributions are welcome! Whether it's a bug fix, feature, or idea — feel free to open a pull request.

  1. Fork the repo
  2. Create your branch: git checkout -b my-feature
  3. Commit your changes: git commit -m 'feat: awesome feature'
  4. Push and open a PR on GitHub

👤 Author

Created by Kledenai
📫 [email protected]
🌍 github.com/kledenai