A javascript library for diffing text and generating corrected and annotated text. This is a fork and derivative of ForbesLindesay/jsdifflib, which is in turn a fork of cemerick/jsdifflib
The main difference between this lib and ForbesLindesay/jsdifflib is jsdifflib
returns an HTML node for direct embedding (a table no less), and this module just returns the adjusted text in a JS object. I was implementing a separate view system, so I just needed the data alone.
npm install diff-compare
diff-compare is a Javascript library that provides:
- a partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class)
- rather than a view generator, as the previous modules have made, this provides a corrected list of items, language agnostic
var diff = require('diff-compare');
var adjustedText = diff.build({
baseText: baseText,
newText: newText
})
// {
// base: [{
// originalLine: 1,
// value: 'abc',
// type: 'delete'
// }, {
// originalLine: 2,
// value: 'def',
// type: 'equal'
// }],
// compare: [{
// originalLine: null,
// value: '',
// type: 'delete'
// }, {
// originalLine: 1,
// value: 'def',
// type: 'equal'
// }]
// }
branch: master
Type | Link | Description |
---|
v1.0.2 | 2015-07-20
branch: release/v1.0.2
Type | Link | Description |
---|---|---|
Added | e66bd85 |
Added badges and changelog to Readme |
v1.0.1 | 2015-07-20
branch: release/v1.0.1
Type | Link | Description |
---|---|---|
Added | 6aa50a7 |
Added badges |
Changed | 6aa50a7 |
Refactored build opts keys |
Fixed | a371e21 |
Code Climate CLI issue |
v1.0.0 | 2015-07-14
branch: release/v1.0.0
Type | Link | Description |
---|---|---|
Added | Initial Release - Converted HTML output to pure JS output |
Dual License: BSD + ISC