# gitdiff-parser

> A fast and reliable git diff parser.

Latest version **0.3.1** (published 2023-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install gitdiff-parser
pnpm add gitdiff-parser
yarn add gitdiff-parser
bun add gitdiff-parser
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2023-03-14 |
| First published | 2017-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 72 |
| Maintainers | otakustay, ecomfe-core |

## Links

- npm: https://www.npmjs.com/package/gitdiff-parser
- Repository: https://github.com/ecomfe/gitdiff-parser
- Homepage: https://github.com/ecomfe/gitdiff-parser#readme
- Issues: https://github.com/ecomfe/gitdiff-parser/issues
- npm.io page: https://npm.io/package/gitdiff-parser

## Recent versions

- 0.3.1 (latest) — 2023-03-14
- 0.3.0 — 2023-02-21
- 0.2.2 — 2020-03-19
- 0.2.1 — 2020-03-17
- 0.2.0 — 2020-03-15
- 0.1.2 — 2018-10-16
- 0.1.1 — 2018-10-15
- 0.1.0 — 2018-09-17
- 0.0.8 — 2017-12-22
- 0.0.7 — 2017-12-07
- 0.0.6 — 2017-12-07
- 0.0.5 — 2017-10-26
- 0.0.3 — 2017-10-23
- 0.0.2 — 2017-10-12
- 0.0.1 — 2017-09-21

## README

# gitdiff-parser

A fast and reliable git diff parser.

## Install

```shell
npm install gitdiff-parser
```

## Usage

```js
import gitDiffParser from 'gitdiff-parser';

gitDiffParser.parse(gitDiffText);
```

`gitDiffText` should be a diff output by `git diff` command.

### API

```ts
export interface Change {
    content: string;
    type: 'insert' | 'delete' | 'normal';
    isInsert?: boolean;
    isDelete?: boolean;
    isNormal?: boolean;
    lineNumber?: number;
    oldLineNumber?: number;
    newLineNumber?: number;
}

export interface Hunk {
    content: string;
    oldStart: number;
    newStart: number;
    oldLines: number;
    newLines: number;
    changes: Change[];
}

export interface File {
    hunks: Hunk[];
    oldEndingNewLine: boolean;
    newEndingNewLine: boolean;
    oldMode: string;
    newMode: string;
    similarity?: number;
    oldRevision: string;
    newRevision: string;
    oldPath: string;
    newPath: string;
    isBinary?: boolean;
    type: 'add' | 'delete' | 'modify' ｜ 'rename';
}

export default {
    parse(source: string): File[];
};
```

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