# fast-diff

> Fast Javascript text diff

Latest version **1.3.0** (published 2023-05-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install fast-diff
pnpm add fast-diff
yarn add fast-diff
bun add fast-diff
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2023-05-19 |
| First published | 2014-10-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 51.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 715 |
| Author | Jason Chen |
| Maintainers | luin, jhchen |
| Keywords | diff |

## Links

- npm: https://www.npmjs.com/package/fast-diff
- Repository: https://github.com/jhchen/fast-diff
- Homepage: https://github.com/jhchen/fast-diff#readme
- Issues: https://github.com/jhchen/fast-diff/issues
- npm.io page: https://npm.io/package/fast-diff

## Recent versions

- 1.3.0 (latest) — 2023-05-19
- 1.2.0 — 2018-10-08
- 1.1.2 — 2017-09-17
- 1.1.1 — 2016-10-23
- 1.1.0 — 2016-10-19
- 1.0.1 — 2015-06-03
- 1.0.0 — 2014-10-03

## README

# Fast Diff ![Build Status](https://github.com/jhchen/fast-diff/actions/workflows/test.yml/badge.svg)

This is a simplified import of the excellent [diff-match-patch](https://code.google.com/p/google-diff-match-patch/) library by [Neil Fraser](https://neil.fraser.name/) into the Node.js environment. The match and patch parts are removed, as well as all the extra diff options. What remains is incredibly fast diffing between two strings.

 The diff function is an implementation of ["An O(ND) Difference Algorithm and its Variations" (Myers, 1986)](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.4.6927&rep=rep1&type=pdf) with the suggested divide and conquer strategy along with several [optimizations](http://neil.fraser.name/news/2007/10/09/) Neil added.

```js
var diff = require('fast-diff');

var good = 'Good dog';
var bad = 'Bad dog';

var result = diff(good, bad);
// [[-1, "Goo"], [1, "Ba"], [0, "d dog"]]

// Respect suggested edit location (cursor position), added in v1.1
diff('aaa', 'aaaa', 1)
// [[0, "a"], [1, "a"], [0, "aa"]]

// For convenience
diff.INSERT === 1;
diff.EQUAL === 0;
diff.DELETE === -1;
```

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