-
-
Notifications
You must be signed in to change notification settings - Fork 1
Installation & Setup
CmpStr is distributed as an npm package and can be used across a wide range of JavaScript environments. It supports modern ESM-based projects, legacy CommonJS setups, and direct usage in the browser via UMD or ESM bundles.
If you are unsure which format to choose, ES modules (ESM) are recommended whenever supported by your environment. The provided ESM and UMD bundles are optimized and minified for production use.
The recommended way to use CmpStr is to install it from npm:
npm install cmpstrThis installs the latest stable release and makes the package available in your local node_modules directory.
CmpStr can be imported in different ways depending on your runtime and module system.
For TypeScript projects or environments using ES modules:
import { CmpStr } from 'cmpstr';ESM support is fully native. Type definitions are bundled with the package, providing IntelliSense and compile-time type safety out of the box.
For Node.js projects that still rely on CommonJS:
const { CmpStr } = require( 'cmpstr' );CmpStr includes CommonJS-compatible exports and works reliably in most legacy Node.js environments.
CmpStr provides prebuilt browser bundles located in the dist/ directory of the package.
You can choose between the following formats:
Use the UMD bundle for maximum compatibility or when no bundler is available:
<script src="./dist/CmpStr.umd.min.js"></script>
<script>
const cmp = CmpStr.CmpStr.create().setMetric( 'levenshtein' );
console.log( cmp.compare( 'kitten', 'sitting' ) );
</script>This exposes the CmpStr namespace on the global window object.
For modern browsers with native ES module support:
<script type="module">
import { CmpStr } from './dist/CmpStr.esm.min.js';
const cmp = CmpStr.create().setMetric( 'levenshtein' );
console.log( cmp.compare( 'kitten', 'sitting' ) );
</script>Note: ESM imports are scoped and do not pollute the global namespace.
CmpStr can also be loaded directly from a jsDelivr CDN without a local installation. This is useful for rapid prototyping, testing, or lightweight client-side integrations.
<script src="https://cdn.jsdelivr.net/npm/cmpstr/dist/CmpStr.umd.min.js"></script><script type="module">
import { CmpStr } from 'https://cdn.jsdelivr.net/npm/cmpstr/dist/CmpStr.esm.min.js';
</script>CmpStr 3.2 / API Reference • FAQ • npm Package • jsDelivr • DevDocs
CmpStr is a lightweight, fast and well performing package for calculating string similarity.
Getting Started
Installation & Setup
Quick Start
API Reference
Documentation
Similarity Metrics
Phonetic Algorithms
Normalization & Filtering
Comparison Modes
Structured Data
Asynchronous API
Diff & Text Analysis
Extending CmpStr
Project Management