
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dice-string-similarity
Advanced tools
String similarity utilities based on Dice's Coefficient (bigram overlap).
A simple and efficient JavaScript utility for comparing string similarity using bigram comparison/Dice's Coefficient. This utility provides functions to compare two strings for their similarity and to find the best match for a given string from an array of strings. This project is a continuation/enhancement of string-similarity originally developed by aceakash.
Install from npm:
npm install dice-string-similarity
This package supports both ESM (import) and CommonJS (require).
import { compare, findBestMatch } from 'dice-string-similarity';
const { compare, findBestMatch } = require('dice-string-similarity');
To compare the similarity between two strings, use the compare function:
import { compare } from 'dice-string-similarity';
const similarityScore = compare('string1', 'string2');
console.log(similarityScore); // Outputs the similarity score between 0 and 1
To find the best match for a string from an array of target strings, use the findBestMatch function:
import { findBestMatch } from 'dice-string-similarity';
const mainString = 'main string to compare';
const targetStrings = ['target string 1', 'target string 2', 'target string 3'];
const bestMatch = findBestMatch(mainString, targetStrings);
console.log(bestMatch); // Outputs the best match object containing `ratings`, `bestMatch`, and `bestMatchIndex`
compare(first, second)first (string): The first string to compare.second (string): The second string to compare.number: The similarity score between the two strings, ranging from 0 to 1.findBestMatch(mainString, targetStrings)mainString (string): The main string to compare against.targetStrings (Array): An array of strings to compare the main string with.ratings: An array of objects, each containing a target string and its rating.bestMatch: The object from ratings with the highest rating.bestMatchIndex: The index of bestMatch in the ratings array.Contributions to the String Similarity are welcome. Please ensure to follow the coding standards and submit your pull requests for review.
This project is open-source and available under the MIT License.
FAQs
String similarity utilities based on Dice's Coefficient (bigram overlap).
The npm package dice-string-similarity receives a total of 342 weekly downloads. As such, dice-string-similarity popularity was classified as not popular.
We found that dice-string-similarity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.