0.0.13 • Published 10 years ago

diff-parse v0.0.13

Weekly downloads
1,419
License
MIT
Repository
github
Last release
10 years ago

diff-parse

Unified diff parser for nodejs

This is straight from parse-diff. I just compiled the coffeescript to javascript because coffeescript complicates things if you just want to use the module.

I also strip the first character for each line because I'm using this for git diffs. It was keeping the '+', '-', and ' ' before the text on each line.

JavaScript Usage Example

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