A module for splitting diffs into chunks
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

diffsplit Build Status

diffsplit is a module for splitting diffs into chunks.

Installation

npm install diffsplit

Usage

var diffsplit = require('diffsplit');
var diff = [
  '@@ -1,6 +1,6 @@ Some heading.',
  ' This is a simple test file.',
  ' ',
  '-It has 10 paragraphs.',
  '+It has many paragraphs.',
  ' ',
  ' However, only few will be modified.',
  ' ',
  '@@ -14,7 +14,7 @@',
  ' ',
  ' It\'s just a simple demonstration of `diffsplit`, a simple and tiny library.',
  ' ',
  '-So, how about modifying this file yet? I really should be working on something',
  '-else instead.',
  '+So, how about modifying this file yet? I really should be working on `diffsplit`',
  '+itself.',
  ' ',
  ' It\'s getting too long.',
].join('\n');
console.dir(diffsplit(diff));

Output:

[ { original: { start: 1, length: 6 },
    new: { start: 1, length: 6 },
    heading: 'Some heading.',
    lines: 
     [ ' This is a simple test file.',
       ' ',
       '-It has 10 paragraphs.',
       '+It has many paragraphs.',
       ' ',
       ' However, only few will be modified.',
       ' ' ] },
  { original: { start: 14, length: 7 },
    new: { start: 14, length: 7 },
    heading: '',
    lines: 
     [ ' ',
       ' It\'s just a simple demonstration of `diffsplit`, a simple and tiny library.',
       ' ',
       '-So, how about modifying this file yet? I really should be working on something',
       '-else instead.',
       '+So, how about modifying this file yet? I really should be working on `diffsplit`',
       '+itself.',
       ' ',
       ' It\'s getting too long.' ] } ]