npm.io
1.1.0 • Published 2 weeks ago

string-typo-match

Licence
MIT
Version
1.1.0
Deps
0
Size
33 kB
Vulns
0
Weekly
0
Stars
214

string-typo-match

Match typing errors against candidate strings with weighted omissions, swaps, and explainable ambiguity

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

No dependencies whatsoever. This package declares no dependencies or devDependencies.

Features

A leven alternative for matching human typing errors against your own dictionary, with optional keyboard awareness and explained suggestions.

  • Treat a missing chunk as one typo, with limits on how much can disappear.
  • Recognise missed keys, extra characters, repeats, substitutions, and adjacent swaps.
  • Enable QWERTY weighting or supply your own keyboard map.
  • Tune error costs and allow one or two typo events.
  • Keep exact matches, rank fuzzy suggestions, and flag ambiguity.
  • Match Unicode code points; explain edits with original-string offsets.
  • Prepare dictionaries once; track progress and completion statistics.
  • Get TypeScript types, ESM, and a standalone browser script without dependencies.

Install

This package is pure ESM.

npm i string-typo-match

Quick Take

import assert from "node:assert/strict";
import { matchTypos } from "string-typo-match";

const result = matchTypos("Lenstein", ["Levenstein", "Einstein"]);
assert.equal(result.bestMatch, "Levenstein");
assert.equal(result.matches[0].operations[0].kind, "omitted-block");

Documentation

Please visit codsen.com for a full description of the API. For Changelog, see raw md on GitHub or the website.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License

Copyright 2010-2026 Roy Revelt and other contributors

ok codsen star

Keywords