{"name":"diff","version":"1.4.0","description":"A javascript text diff implementation.","keywords":["diff","javascript"],"maintainers":[{"name":"Kevin Decker","email":"kpdecker@gmail.com","url":"http://incaseofstairs.com"}],"bugs":{"url":"http://github.com/kpdecker/jsdiff/issues","email":"kpdecker@gmail.com"},"licenses":[{"type":"BSD","url":"http://github.com/kpdecker/jsdiff/blob/master/LICENSE"}],"repository":{"type":"git","url":"git://github.com/kpdecker/jsdiff.git"},"engines":{"node":">=0.3.1"},"main":"./diff","scripts":{"test":"istanbul cover node_modules/.bin/_mocha test/*.js && istanbul check-coverage --statements 100 --functions 100 --branches 100 --lines 100 coverage/coverage.json"},"dependencies":{},"devDependencies":{"colors":"^1.1.0","istanbul":"^0.3.2","mocha":"^2.2.4","should":"^6.0.1"},"optionalDependencies":{},"files":["diff.js"],"readme":"# jsdiff\n\n[![Build Status](https://secure.travis-ci.org/kpdecker/jsdiff.png)](http://travis-ci.org/kpdecker/jsdiff)\n\nA javascript text differencing implementation.\n\nBased on the algorithm proposed in\n[\"An O(ND) Difference Algorithm and its Variations\" (Myers, 1986)](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927).\n\n## Installation\n\n    npm install diff\n\nor\n\n    bower install jsdiff\n\nor\n\n    git clone git://github.com/kpdecker/jsdiff.git\n\n## API\n\n* `JsDiff.diffChars(oldStr, newStr[, callback])` - diffs two blocks of text, comparing character by character.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffWords(oldStr, newStr[, callback])` - diffs two blocks of text, comparing word by word, ignoring whitespace.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffWordsWithSpace(oldStr, newStr[, callback])` - diffs two blocks of text, comparing word by word, treating whitespace as significant.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffLines(oldStr, newStr[, callback])` - diffs two blocks of text, comparing line by line.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffTrimmedLines(oldStr, newStr[, callback])` - diffs two blocks of text, comparing line by line, ignoring leading and trailing whitespace.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffSentences(oldStr, newStr[, callback])` - diffs two blocks of text, comparing sentence by sentence.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffCss(oldStr, newStr[, callback])` - diffs two blocks of text, comparing CSS tokens.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.diffJson(oldObj, newObj[, callback])` - diffs two JSON objects, comparing the fields defined on each. The order of fields, etc does not matter in this comparison.\n\n    Returns a list of change objects (See below).\n\n* `JsDiff.createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader)` - creates a unified diff patch.\n\n    Parameters:\n    * `oldFileName` : String to be output in the filename section of the patch for the removals\n    * `newFileName` : String to be output in the filename section of the patch for the additions\n    * `oldStr` : Original string value\n    * `newStr` : New string value\n    * `oldHeader` : Additional information to include in the old file header\n    * `newHeader` : Additional information to include in thew new file header\n\n* `JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)` - creates a unified diff patch.\n\n    Just like JsDiff.createTwoFilesPatch, but with oldFileName being equal to newFileName.\n\n* `JsDiff.applyPatch(oldStr, diffStr)` - applies a unified diff patch.\n\n    Return a string containing new version of provided data.\n\n* `convertChangesToXML(changes)` - converts a list of changes to a serialized XML format\n\n\nAll methods above which accept the optional callback method will run in sync mode when that parameter is omitted and in async mode when supplied. This allows for larger diffs without blocking the event loop.\n\n### Change Objects\nMany of the methods above return change objects. These objects are consist of the following fields:\n\n* `value`: Text content\n* `added`: True if the value was inserted into the new string\n* `removed`: True of the value was removed from the old string\n\nNote that some cases may omit a particular flag field. Comparison on the flag fields should always be done in a truthy or falsy manner.\n\n## Examples\n\nBasic example in Node\n\n```js\nrequire('colors')\nvar jsdiff = require('diff');\n\nvar one = 'beep boop';\nvar other = 'beep boob blah';\n\nvar diff = jsdiff.diffChars(one, other);\n\ndiff.forEach(function(part){\n  // green for additions, red for deletions\n  // grey for common parts\n  var color = part.added ? 'green' :\n    part.removed ? 'red' : 'grey';\n  process.stderr.write(part.value[color]);\n});\n\nconsole.log()\n```\nRunning the above program should yield\n\n<img src=\"images/node_example.png\" alt=\"Node Example\">\n\nBasic example in a web page\n\n```html\n<pre id=\"display\"></pre>\n<script src=\"diff.js\"></script>\n<script>\nvar one = 'beep boop';\nvar other = 'beep boob blah';\n\nvar diff = JsDiff.diffChars(one, other);\n\ndiff.forEach(function(part){\n  // green for additions, red for deletions\n  // grey for common parts\n  var color = part.added ? 'green' :\n    part.removed ? 'red' : 'grey';\n  var span = document.createElement('span');\n  span.style.color = color;\n  span.appendChild(document\n    .createTextNode(part.value));\n  display.appendChild(span);\n});\n</script>\n```\n\nOpen the above .html file in a browser and you should see\n\n<img src=\"images/web_example.png\" alt=\"Node Example\">\n\n**[Full online demo](http://kpdecker.github.com/jsdiff)**\n\n## License\n\nSoftware License Agreement (BSD License)\n\nCopyright (c) 2009-2011, Kevin Decker kpdecker@gmail.com\n\nAll rights reserved.\n\nRedistribution and use of this software in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above\n  copyright notice, this list of conditions and the\n  following disclaimer.\n\n* Redistributions in binary form must reproduce the above\n  copyright notice, this list of conditions and the\n  following disclaimer in the documentation and/or other\n  materials provided with the distribution.\n\n* Neither the name of Kevin Decker nor the names of its\n  contributors may be used to endorse or promote products\n  derived from this software without specific prior\n  written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kpdecker/jsdiff/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","readmeFilename":"README.md","homepage":"https://github.com/kpdecker/jsdiff","_id":"diff@1.4.0","_shasum":"7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf","_from":"https://registry.npmjs.org/diff/-/diff-1.4.0.tgz","_resolved":"https://registry.npmjs.org/diff/-/diff-1.4.0.tgz"}