Skip to content

type-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.

License

Notifications You must be signed in to change notification settings

techboy-coder/typer-diff

Repository files navigation

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 };

About

type-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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy