Registry /
serialization / jaro-winkler-typescript
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
jaro
✓ import { jaro } from 'jaro-winkler-typescript';
✗ const { jaro } = require('jaro-winkler-typescript');
This package is designed for ESM/TypeScript; CommonJS require() syntax for named exports is not directly supported and can lead to runtime errors.
jaroWinkler
✓ import { jaroWinkler } from 'jaro-winkler-typescript';
✗ import jaroWinkler from 'jaro-winkler-typescript';
Both `jaro` and `jaroWinkler` are named exports. Attempting a default import will result in 'undefined' or a 'TypeError'.
JaroWinklerOptions
✓ import type { JaroWinklerOptions } from 'jaro-winkler-typescript';
When only importing types for type annotations, use `import type` for clarity and to ensure it's removed during compilation if not needed at runtime.
Demonstrates basic usage of Jaro and Jaro-Winkler algorithms, including case-sensitive and case-insensitive comparisons, and interpretation of similarity scores.
import { jaro, jaroWinkler } from "jaro-winkler-typescript";
// Example 1: Basic comparison for Jaro similarity
const stringA = "MARTHA";
const stringB = "MARHTA";
const similarityJaro = jaro(stringA, stringB);
console.log(`Jaro similarity between "${stringA}" and "${stringB}": ${similarityJaro.toFixed(4)}`);
// Expected output: Jaro similarity between "MARTHA" and "MARHTA": 0.9444
// Example 2: Basic comparison for Jaro-Winkler similarity
const stringC = "DWAYNE";
const stringD = "DUANE";
const similarityJaroWinkler = jaroWinkler(stringC, stringD);
console.log(`Jaro-Winkler similarity between "${stringC}" and "${stringD}": ${similarityJaroWinkler.toFixed(4)}`);
// Expected output: Jaro-Winkler similarity between "DWAYNE" and "DUANE": 0.8400
// Example 3: Case-insensitive comparison
const name1 = "JavaScript";
const name2 = "javascript";
const insensitiveJaro = jaro(name1, name2, { caseSensitive: false });
console.log(`Case-insensitive Jaro similarity between "${name1}" and "${name2}": ${insensitiveJaro.toFixed(4)}`);
// Expected output: Case-insensitive Jaro similarity between "JavaScript" and "javascript": 1.0000
// Example 4: Comparing strings with significant differences
const word1 = "hello";
const word2 = "world";
const jaroScore = jaro(word1, word2);
const jaroWinklerScore = jaroWinkler(word1, word2);
console.log(`Jaro score for "${word1}" and "${word2}": ${jaroScore.toFixed(4)}`);
console.log(`Jaro-Winkler score for "${word1}" and "${word2}": ${jaroWinklerScore.toFixed(4)}`);
// Expected output: Jaro score for "hello" and "world": 0.4444, Jaro-Winkler score for "hello" and "world": 0.4444
Errors
Common errors & fixes
TypeError: (0 , jaro_winkler_typescript__WEBPACK_IMPORTED_MODULE_0__.jaro) is not a function
Attempting to import `jaro` or `jaroWinkler` using CommonJS `require()` syntax in an environment that expects ESM, or incorrect destructuring.
fixEnsure your project is configured for ESM and use `import { jaro } from 'jaro-winkler-typescript';`. If using CommonJS, it may require transpilation or a different package. TypeError: jaro is not a function
This typically occurs when trying to access `jaro` or `jaroWinkler` after using a default import (`import jaro from '...'`) for a package that only provides named exports, or attempting `const jaro = require(...)` without destructuring.
fixUse named imports: `import { jaro, jaroWinkler } from 'jaro-winkler-typescript';` Argument of type 'number' is not assignable to parameter of type 'string'.
Passing a non-string value (e.g., a number or null) to the `jaro` or `jaroWinkler` function, which expects two string arguments.
fixEnsure both arguments passed to `jaro` and `jaroWinkler` are strings. Validate input types before calling the functions.
Audit
Dependencies
No dependency data recorded yet.