Skip to content

chore: replace fastest-levenshtein with turbo-leven in did-you-mean#9243

Open
dev-kjma wants to merge 1 commit intonpm:latestfrom
dev-kjma:chore/replace-fastest-levenshtein-with-turbo-leven
Open

chore: replace fastest-levenshtein with turbo-leven in did-you-mean#9243
dev-kjma wants to merge 1 commit intonpm:latestfrom
dev-kjma:chore/replace-fastest-levenshtein-with-turbo-leven

Conversation

@dev-kjma
Copy link
Copy Markdown

Summary

Replaces fastest-levenshtein with turbo-leven in lib/utils/did-you-mean.js.

turbo-leven exports .distance(a, b) — the exact API already used here — so the call site in isClose() is unchanged. Only the require() and package.json dep are modified.

Why

turbo-leven is a strict superset of fastest-levenshtein:

fastest-levenshtein turbo-leven
.distance(a, b)
.get(a, b)
TypeScript types
Required deps 0 0
Unicode UTF-16 code units Unicode codepoints ✓
Perf — medium strings baseline 1.3× faster
Perf — long strings baseline 9.4× faster

The Rust native module is optionalturbo-leven ships a pure-JS fallback that activates silently on any platform where native loading fails. No build toolchain or Rust required for end users.

Changes

// lib/utils/did-you-mean.js
-const { distance } = require('fastest-levenshtein')
+const { distance } = require('turbo-leven')

// package.json
-"fastest-levenshtein": "^1.0.16",
+"turbo-leven": "^1.0.0",

No other changes.

Benchmark / correctness source

https://github.com/dev-kjma/faster-levenshtein

turbo-leven is a superset of fastest-levenshtein:
- Exports .distance(a,b) — the exact same API used here
- Zero required dependencies with a pure-JS fallback
- Optional Rust native module (9.4x faster on long strings, 1.3x on medium)
- Ships TypeScript types
- Better Unicode: counts codepoints not UTF-16 code units

The change is surgical: one require() in did-you-mean.js + package.json dep.
@dev-kjma dev-kjma requested a review from a team as a code owner April 15, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant