Skip to content

sergeyt/parse-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 20, 2023
a916dbc · Mar 20, 2023
Dec 16, 2021
Mar 16, 2023
Mar 12, 2021
Jan 6, 2014
Sep 29, 2018
Jan 6, 2014
Mar 12, 2021
Mar 11, 2021
Jan 19, 2023
Mar 20, 2023
Mar 20, 2023
Mar 20, 2023
Mar 20, 2023

Repository files navigation

Build Status Total downloads

NPM

parse-diff

Simple unified diff parser for JavaScript

JavaScript Usage Example

var parse = require('parse-diff');
var diff = ''; // input diff string
var files = parse(diff);
console.log(files.length); // number of patched files
files.forEach(function(file) {
	console.log(file.chunks.length); // number of hunks
	console.log(file.chunks[0].changes.length) // hunk added/deleted/context lines
	// each item in changes is a string
	console.log(file.deletions); // number of deletions in the patch
	console.log(file.additions); // number of additions in the patch
});