Jsdiff supports all ES3 environments with some known issues on IE8 and below. html file in a browser and you should see The data structure returned may look like this: Parameters are the same as createTwoFilesPatch. This method is similar to createTwoFilesPatch, but returns a data structure Just like Diff.createTwoFilesPatch, but with oldFileName being equal to newFileName.ĭiff.structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) - returns an object with an array of hunk objects. ignoreWhitespace: true to ignore leading and trailing whitespace.ĭiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader) - creates a unified diff patch.context describes how many lines of context should be included.newHeader : Additional information to include in the new file header.oldHeader : Additional information to include in the old file header. newFileName : String to be output in the filename section of the patch for the additions.oldFileName : String to be output in the filename section of the patch for the removals.comparator: function(left, right) for custom equality checksĭiff.createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader) - creates a unified diff patch.The order of fields, etc does not matter in this comparison.ĭiff.diffArrays(oldArr, newArr) - diffs two arrays, comparing each item for strict equality (=). In general this is the more human friendly form of diffLines and diffLines is better suited for patches and other computer friendly output.ĭiff.diffTrimmedLines(oldStr, newStr) - diffs two blocks of text, comparing line by line, ignoring leading and trailing whitespace.ĭiff.diffSentences(oldStr, newStr) - diffs two blocks of text, comparing sentence by sentence.ĭiff.diffCss(oldStr, newStr) - diffs two blocks of text, comparing CSS tokens.ĭiff.diffJson(oldObj, newObj) - diffs two JSON objects, comparing the fields defined on each. This allows for changes to the newline structure to occur independently of the line content and to be treated as such. newlineIsToken: true to treat newline characters as separate tokens.ignoreWhitespace: true to ignore leading and trailing whitespace.Defaults to false.ĭiff.diffWords(oldStr, newStr) - diffs two blocks of text, comparing word by word, ignoring whitespace.ĭiff.diffWordsWithSpace(oldStr, newStr) - diffs two blocks of text, comparing word by word, treating whitespace as significant.ĭiff.diffLines(oldStr, newStr) - diffs two blocks of text, comparing line by line. ignoreCase: true to ignore casing difference.Returns a list of change objects (See below). Diff.diffChars(oldStr, newStr) - diffs two blocks of text, comparing character by character.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |