JSPM

diff-match-patch-line-and-word

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16213
  • Score
    100M100P100Q155074F
  • License MIT

An extension module that adds line-mode and word-mode on diff-match-patch.

Package Exports

  • diff-match-patch-line-and-word
  • diff-match-patch-line-and-word/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (diff-match-patch-line-and-word) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Diff Patch Merge Line and Word

What's this

An extension module that adds line-mode and word-mode on google-diff-match-patch, hosted as diff-patch-merge at NPM, originally by Neil Fraser.

Implementation is from Wiki.

TypeScript is also supported.

API

Methods

diff_lineMode

Execute diff_main line-by-line.

Parameter
Parameter Type Description
text1 string Old text to compare.
text2 string New text to compare.
Return value
Type Description
Array of diff_patch_merge.Diff result diff tuples.

diff_wordMode

Execute diff_main word-by-word.

The signature is same.

How to use

Just import after node-diff-patch-merge.

Example:

import { diff_match_patch } from 'diff-match-patch';
import 'diff-match-patch-line-and-word'; // import globally to  enhanse the class.

const dmp = new diff_match_patch();
const oldText = 'He writes the letter.';
const newText = 'She wrote the letters.';

const diffs = dmp.diff_lineMode(oldText, newText);
const html = dmp.diff_prettyHtml(diffs));

document.write(html);