GitShow/antfu/diff-match-patch-es
antfu

diff-match-patch-es

ESM and TypeScript rewrite of Google's diff-match-patch for JavaScript

by antfu
dff-match-patchdiffesmjavascripttypescript
Star on GitHubForknpm

TypeScript

197 stars6 forks4 contributorsActive · 5d agoSince 2024v2.0.1Apache-2.0

Meet the team

See all 4 on GitHub →
antfu
antfu14 contributions
antfubot
antfubot2 contributions
anubra266
anubra2661 contribution
leekoho
leekoho1 contribution

Languages

View on GitHub →
TypeScript99.9%
JavaScript0.1%

Commit activity

Last 12 weeks · 4 commits

Full graph →

Community health

5 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template✓PR Template

Recent PRs & issues

Active · 2 discussions · Last activity 5d ago
See all on GitHub →
aforemendude
diffCleanupSemantic(Lossless) can run into an infinite loopOpenIssue

Describe the bug For a specifically crafted input, would produce a delta that cause and to hang (infinite loop). The documentation for says that it would throw on invalid input, but it's not doing that for this case. Or this could be an issue with and where they are mishandling specific diffs. This is happening due to the empty edit/equality tuples. Reproducible on the latest . Reproduction: Potential fix (unverified): The original Java version has some extra check: https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/java/src/name/fraser/neil/plaintext/diff_match_patch.java#L938-L939 But missing from the JS (and TS) version: https://github.com/antfu/diff-match-patch-es/blob/4f35fb7fd57df68d69068cdee0780bb779f5497f/src/diff.ts#L880 Reproduction https://github.com/aforemendude/bugs-reproduction/tree/main/diff-match-patch-es-delta-inf-loop System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

aforemendude · 4d ago
aforemendude
diffToDelta and patchToText can throw if diff split surrogate-pairOpenIssue

Describe the bug The current implementation operates on UTF-16 characters directly, which can cause it to split surrogate-pairs. When this happens, and can throw . Reproducible on the latest . Reproduction: Output: Reproduction https://github.com/aforemendude/bugs-reproduction/tree/main/diff-match-patch-es-urierror System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [ ] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

aforemendude · 4d ago

Recent fixes

View closed PRs →
aforemendude
Unexpected output when __proto__ is the final lineClosedIssue

Describe the bug For line diffs, when is the final line (without trailing new line), identical inputs receive different character IDs and duplicate entries in the line table. This issue is happening to the latest . Reproduction: Following the line diff example here: https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs Output: Possible fix (unverified): https://github.com/antfu/diff-match-patch-es/blob/8c9aa5df9ba220c3742f8eab20f129ba9c04b685/src/diff.ts#L390 Change to or a . Please let me know if you want me to open a PR. Reproduction https://github.com/aforemendude/bugs-reproduction/blob/main/diff-match-patch-es-proto-edge-case/ System Info Used Package Manager npm Validations [x] Follow our Code of Conduct [x] Read the Contributing Guide. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [x] The provided reproduction is a minimal reproducible of the bug. Contributions [x] I am willing to submit a PR to fix this issue [ ] I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

aforemendude · 5d ago
leekoho
feat: export `diffLinesToChars` and `diffCharsToLines` functionMergedPR

Description 原仓库中推荐的用到了这两个方法(链接) Linked Issues Additional context

leekoho · 1y ago
anubra266
Fix Readme typoMergedPR

Fix Readme typo

anubra266 · 2y ago
Structured data for AI agents

Repository: antfu/diff-match-patch-es. Description: ESM and TypeScript rewrite of Google's diff-match-patch for JavaScript Stars: 197, Forks: 6. Primary language: TypeScript. Languages: TypeScript (99.9%), JavaScript (0.1%). License: Apache-2.0. Topics: dff-match-patch, diff, esm, javascript, typescript. Latest release: v2.0.1 (5d ago). Open PRs: 0, open issues: 2. Last activity: 5d ago. Community health: 85%. Top contributors: antfu, antfubot, anubra266, leekoho.

·@ofershap

Replace github.com with gitshow.dev