typer-diff
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Typer Diff

Typer Diff Demo

typer-diff is a library to diff two strings, useful for showing for typing games (like monkeytype) or for showing differences between two strings. It is a simple library that is easy to use and has no dependencies. It is also very fast and lightweight.

Check out a demo at typer-diff.vercel.app.

Usage

Usage:

import { diff } from "typer-diff";

// ...
return diff(text.original, text.text);
// ...

Types:

type DiffItem = {
    value: string;
    type: "correct" | "extra" | "missing" | "wrong" | "untouched" | "spacer";
};
type DiffResult = {
    diff: DiffItem[];
    end: boolean;
};
declare const diff: (originalText: string, typedText: string) => DiffResult;

export { type DiffItem, type DiffResult, diff };

Package Sidebar

Install

npm i typer-diff

Weekly Downloads

423

Version

1.1.1

License

MIT

Unpacked Size

17.7 kB

Total Files

12

Last publish

Collaborators

  • shividotio