# what-the-diff

> diff parsing library

Latest version **0.6.0** (published 2019-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install what-the-diff
pnpm add what-the-diff
yarn add what-the-diff
bun add what-the-diff
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2019-03-11 |
| First published | 2016-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 77.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Katrina Uychaco |
| Maintainers | binarymuse, kuychaco |
| Keywords | diff, parser |

## Links

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

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2019-03-11
- 0.5.0 — 2018-12-19
- 0.4.0 — 2018-01-05
- 0.3.0 — 2017-01-13
- 0.2.0 — 2016-11-04
- 0.1.1 — 2016-09-10
- 0.1.0 — 2016-09-10

## README

# JavaScript Diff Parser

![](https://pbs.twimg.com/media/ByZVWXgIIAA5Y2D.png:large)

Credit: [@eightballart](https://twitter.com/EightballArt/status/515195030546690048)

Parse unified diffs with JavaScript

## Installation

what-the-diff is available via npm

    npm install what-the-diff


## Usage

```javascript
let {parse} = require('what-the-diff')

var str = `diff --git file.txt file.txt
index 83db48f..bf269f4 100644
--- file.txt
+++ file.txt
@@ -1,3 +1,3 @@
line1
-line2
+new line
line3`

parse(diffStr)

// returns
  {
    oldPath: 'file.txt',
    newPath: 'file.txt',
    oldMode: '100644',
    newMode: '100644',
    status: 'modified',
    hunks: [
      {
        oldStartLine: 1,
        oldLineCount: 3,
        newStartLine: 1,
        newLineCount: 3,
        lines: [
          ' line1',
          '-line2',
          '+new line',
          ' line3'
        ]
      }
    ]
  }
```

If the diff includes a similarity index line (from a detected copy or rename), the `similarity` property will be set, and will be a number.

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