
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
CmpStr is a lightweight, fast and well performing package for calculating string similarity
CmpStr is a TypeScript library for advanced string comparison, similarity measurement, phonetic indexing, and text analysis. It includes implementations of several established algorithms such as Levenshtein, Dice–Sørensen, Damerau–Levenshtein and Soundex. The library has no external dependencies and allows for the integration of custom metrics, phonetic mappings, and normalization filters.
CmpStr provides a unified API for single, batch and pairwise operations. It is suitable for a range of use cases in application development and research. The package includes support for both ESM and CommonJS environments, TypeScript type declarations and a browser-compatible JavaScript bundle.
Originally launched in 2023 with a minimal feature set, the library was redesigned in 2025 to support a broader set of algorithms and processing features. The current version offers asynchronous operation, configurable normalization and filtering pipelines, phonetic search functionality, and basic tools for string differencing.
Key Features
Working with CmpStr is simple and straightforward. The package is installed just like any other using the following command:
npm install cmpstr
Minimal usage example:
import { CmpStr } from 'cmpstr';
const cmp = CmpStr.create().setMetric( 'levenshtein' ).setFlags( 'i' );
const result = cmp.test( [ 'hello', 'hola' ], 'Hallo' );
console.log( result );
// { source: 'hello', target: 'Hallo', match: 0.8 }
For asynchronous workloads:
import { CmpStrAsync } from 'cmpstr';
const cmp = CmpStrAsync.create().setProcessors( {
phonetic: { algo: 'soundex' }
} );
const result = await cmp.searchAsync( 'Maier', [
'Meyer', 'Müller', 'Miller', 'Meyers', 'Meier'
] );
console.log( result );
// [ 'Meyer', 'Meier' ]
Try with OneCompiler.
Try out or use CmpStr on the terminal. Install the cmpstr-cli package and use many features of CmpStr directly on the console via the cmpstr command. Many options and parameters also make the command suitable for scripts and automatic processing.
The full documentation, API reference and advanced usage examples are available in the GitHub Wiki.
LICENSE MIT © 2023-2025 PAUL KÖHLER (KOMED3)
FAQs
CmpStr is a lightweight, fast and well performing package for calculating string similarity
The npm package cmpstr receives a total of 195 weekly downloads. As such, cmpstr popularity was classified as not popular.
We found that cmpstr 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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.