Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 94 lines (63 sloc) 3.438 kb
30f26cb4 » kpdecker
2011-03-29 Basic readme
1 # jsdiff
2
3 A javascript text differencing implementation.
4
5 Based on the algorithm proposed in
6 ["An O(ND) Difference Algorithm and its Variations" (Myers, 1986)](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927).
7
d0eaa685 » kpdecker
2011-03-29 Install info
8 ## Installation
9
10 npm install diff
11
12 or
13
14 git clone git://github.com/kpdecker/jsdiff.git
15
c3026bc4 » kpdecker
2011-03-29 API documentation
16 ## API
17
18 * JsDiff.diffChars(oldStr, newStr)
19 Diffs two blocks of text, comparing character by character.
20
21 Returns a list of change objects (See below).
22
23 * JsDiff.diffWords(oldStr, newStr)
24 Diffs two blocks of text, comparing word by word.
25
26 Returns a list of change objects (See below).
27
28 * JsDiff.diffLines(oldStr, newStr)
29 Diffs two blocks of text, comparing line by line.
30
31 Returns a list of change objects (See below).
32
33 * JsDiff.diffCss(oldStr, newStr)
34 Diffs two blocks of text, comparing CSS tokens.
35
36 Returns a list of change objects (See below).
37
38 * JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)
39 Creates a unified diff patch.
40
41 Parameters:
42 * fileName : String to be output in the filename sections of the patch
43 * oldStr : Original string value
44 * newStr : New string value
45 * oldHeader : Additional information to include in the old file header
46 * newHeader : Additional information to include in thew new file header
47
48 * convertChangesToXML(changes)
49 Converts a list of changes to a serialized XML format
50
51 ### Change Objects
52 Many of the methods above return change objects. These objects are consist of the following fields:
53
54 * value: Text content
55 * added: True if the value was inserted into the new string
56 * removed: True of the value was removed from the old string
57
58 Note that some cases may omit a particular flag field. Comparison on the flag fields should always be done in a truthy or falsy manner.
59
3a155f65 » kpdecker
2011-08-22 Update example url
60 ## [Example](http://kpdecker.github.com/jsdiff)
859240d7 » kpdecker
2011-05-08 Add example link
61
30f26cb4 » kpdecker
2011-03-29 Basic readme
62 ## License
63
64 Software License Agreement (BSD License)
65
319380f0 » kpdecker
2011-03-29 Prevent markdown parser puke in license section
66 Copyright (c) 2009-2011, Kevin Decker kpdecker@gmail.com
30f26cb4 » kpdecker
2011-03-29 Basic readme
67
68 All rights reserved.
69
70 Redistribution and use of this software in source and binary forms, with or without modification,
71 are permitted provided that the following conditions are met:
72
73 * Redistributions of source code must retain the above
74 copyright notice, this list of conditions and the
75 following disclaimer.
76
77 * Redistributions in binary form must reproduce the above
78 copyright notice, this list of conditions and the
79 following disclaimer in the documentation and/or other
80 materials provided with the distribution.
81
82 * Neither the name of Kevin Decker nor the names of its
83 contributors may be used to endorse or promote products
84 derived from this software without specific prior
85 written permission.
86
87 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
88 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
89 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
91 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
92 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
93 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
94 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Something went wrong with that request. Please try again.