Skip to content

getEditDistance

The optimal-string-alignment distance: insertions, deletions, substitutions and swaps of two adjacent characters, each one edit, so the commonest typos (a missed, doubled, wrong or swapped key) all cost one.

Import:

import { getEditDistance } from '@mnaoumov/obsidian-lib/broken-link-candidates';

Signature:

function getEditDistance(source: string, target: string, limit: number): number

Parameters:

Parameter Type Description
source string The first string.
target string The second string.
limit number The largest distance of interest.

Returns: number — The distance, or limit + 1 once it is certain to exceed limit.