New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

diff-match-patch-line-and-word

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff-match-patch-line-and-word

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

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17K
decreased by-5.69%
Maintainers
1
Weekly downloads
 
Created
Source

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
ParameterTypeDescription
text1stringOld text to compare.
text2stringNew text to compare.
Return value
TypeDescription
Array of diff_patch_merge.Diffresult 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);

Keywords

FAQs

Package last updated on 23 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc