Skip to content

lez/word-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

word-diff

word-diff is a word based inline string diff library, based on John Resig's Javascript Diff Algorithm. Focus is put on producing comprehensible diff instead of a compact one. The diff consists of the minimal count of items describing changes in the string. Both the original and the changed string can be reproduced from the diff. Whitespace-only differences are ignored.

Installation

Installing word-diff

  $ [sudo] npm install word-diff

Usage

This module can be used to generate word based diff for two strings.

    var worddiff = require('word-diff');

    worddiff.diffString(
        'what a great time to be alive',
        'how great it is to be alive'
    )

    // returns:
    [
        {'remove': 'what a ', 'add': 'how '},
        {'text': 'great '},
        {'remove': 'time ', 'add': 'it is '},
        {'text': 'to be alive'}
    ]

For more examples, have a look at the tests.

About

word based string diff library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published