Node Edit Distance CLI
Node Edit Distance — a runnable typescript project with source, install and run commands, and expected output.
Project
node-edit-distance-cli
Entry point: lev.mjs
Install
node lev.mjs kitten sittingRun
node lev.mjs kitten sittingTest
node --test lev.test.mjsExpected output
Computes the Levenshtein edit distance between two strings via the classic DP table.Dependencies
- node >=20
Verification evidence
Source reviewed against typescript standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Node Edit Distance CLI is a self-contained typescript command-line program. Computes the Levenshtein edit distance between two strings via the classic DP table.
Install and run
node lev.mjs kitten sitting
node lev.mjs kitten sitting
Project structure
node-edit-distance-cli/
├── lev.mjs
└── README snippet above
Key source
// lev.mjs
const a=process.argv[2],b=process.argv[3];
const d=Array.from({length:a.length+1},()=>new Array(b.length+1));
for(let i=0;i<=a.length;i++)d[i][0]=i;
for(let j=0;j<=b.length;j++)d[0][j]=j;
for(let i=1;i<=a.length;i++)for(let j=1;j<=b.length;j++)d[i][j]=a[i-1]===b[j-1]?d[i-1][j-1]:1+Math.min(d[i-1][j],d[i][j-1],d[i-1][j-1]);
console.log(d[a.length][b.length]);
Testing
node --test lev.test.mjs
Expected output
When run with the documented command, the program prints:
3 (kitten -> sitting)
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.