# diff-match-patch-line-and-word

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

Latest version **0.1.3** (published 2021-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install diff-match-patch-line-and-word
pnpm add diff-match-patch-line-and-word
yarn add diff-match-patch-line-and-word
bun add diff-match-patch-line-and-word
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2021-11-23 |
| First published | 2017-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Karak |
| Maintainers | karak |
| Keywords | diff, diff-match-patch |

## Links

- npm: https://www.npmjs.com/package/diff-match-patch-line-and-word
- Repository: https://github.com/karak/diff-match-patch-line-and-word
- Homepage: https://github.com/karak/diff-match-patch-line-and-word#readme
- Issues: https://github.com/karak/diff-match-patch-line-and-word/issues
- npm.io page: https://npm.io/package/diff-match-patch-line-and-word

## Recent versions

- 0.1.3 (latest) — 2021-11-23
- 0.1.2 — 2017-10-12
- 0.1.1 — 2017-10-12
- 0.1.0 — 2017-10-12

## README

Diff Patch Merge Line and Word
====

What's this
----

An extension module that adds line-mode and word-mode on <tt>[google-diff-match-patch](https://code.google.com/archive/p/google-diff-match-patch/)</tt>, 
hosted as <tt>diff-patch-merge</tt> at NPM, originally by Neil Fraser.

Implementation is from [Wiki](
https://code.google.com/archive/p/google-diff-match-patch/wikis/LineOrWordDiffs.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 <tt>node-diff-patch-merge</tt>.

### Example:

```javascript
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);
```

---
_Source: https://npm.io/package/diff-match-patch-line-and-word · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
