diff
- Version 9.0.0
- Published
- 616 kB
- No dependencies
- BSD-3-Clause license
Install
npm i diffyarn add diffpnpm add diffOverview
A JavaScript text diff implementation.
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Variables
variable arrayDiff
const arrayDiff: ArrayDiff<unknown>;variable characterDiff
const characterDiff: CharacterDiff;variable cssDiff
const cssDiff: CssDiff;variable FILE_HEADERS_ONLY
const FILE_HEADERS_ONLY: { includeIndex: boolean; includeUnderline: boolean; includeFileHeaders: boolean;};variable INCLUDE_HEADERS
const INCLUDE_HEADERS: { includeIndex: boolean; includeUnderline: boolean; includeFileHeaders: boolean;};variable jsonDiff
const jsonDiff: JsonDiff;variable lineDiff
const lineDiff: LineDiff;variable OMIT_HEADERS
const OMIT_HEADERS: { includeIndex: boolean; includeUnderline: boolean; includeFileHeaders: boolean;};variable sentenceDiff
const sentenceDiff: SentenceDiff;variable wordDiff
const wordDiff: WordDiff;variable wordsWithSpaceDiff
const wordsWithSpaceDiff: WordsWithSpaceDiff;Functions
function applyPatch
applyPatch: ( source: string, patch: string | StructuredPatch | [StructuredPatch], options?: ApplyPatchOptions) => string | false;attempts to apply a unified diff patch.
Hunks are applied first to last.
applyPatchfirst tries to apply the first hunk at the line number specified in the hunk header, and with all context lines matching exactly. If that fails, it tries scanning backwards and forwards, one line at a time, to find a place to apply the hunk where the context lines match exactly. If that still fails, andfuzzFactoris greater than zero, it increments the maximum number of mismatches (missing, extra, or changed context lines) that there can be between the hunk context and a region where we are trying to apply the patch such that the hunk will still be considered to match. Regardless offuzzFactor, lines to be deleted in the hunk *must* be present for a hunk to match, and the context lines *immediately* before and after an insertion must match exactly.Once a hunk is successfully fitted, the process begins again with the next hunk. Regardless of
fuzzFactor, later hunks must be applied later in the file than earlier hunks.If a hunk cannot be successfully fitted *anywhere* with fewer than
fuzzFactormismatches,applyPatchfails and returnsfalse.If a hunk is successfully fitted but not at the line number specified by the hunk header, all subsequent hunks have their target line number adjusted accordingly. (e.g. if the first hunk is applied 10 lines below where the hunk header said it should fit,
applyPatchwill *start* looking for somewhere to apply the second hunk 10 lines below where its hunk header says it goes.)If the patch was applied successfully, returns a string containing the patched text. If the patch could not be applied (because some hunks in the patch couldn't be fitted to the text in
source),applyPatchreturns false.Parameter patch
a string diff or the output from the
parsePatchorstructuredPatchmethods.
function applyPatches
applyPatches: ( uniDiff: string | StructuredPatch[], options: ApplyPatchesOptions) => void;applies one or more patches.
patchmay be either an array of structured patch objects, or a string representing a patch in unified diff format (which may patch one or more files).This method will iterate over the contents of the patch and apply to data provided through callbacks. The general flow for each patch index is:
-
options.loadFile(index, callback)is called. The caller should then load the contents of the file and then pass that to thecallback(err, data)callback. Passing anerrwill terminate further patch execution. -options.patched(index, content, callback)is called once the patch has been applied.contentwill be the return value fromapplyPatch. When it's ready, the caller should callcallback(err)callback. Passing anerrwill terminate further patch execution.Once all patches have been applied or an error occurs, the
options.complete(err)callback is made.
function canonicalize
canonicalize: ( obj: any, stack: Array<any> | null, replacementStack: Array<any> | null, replacer: (k: string, v: any) => any, key?: string) => any;function convertChangesToDMP
convertChangesToDMP: <ValueT>( changes: ChangeObject<ValueT>[]) => [DmpOperation, ValueT][];converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library
function convertChangesToXML
convertChangesToXML: (changes: ChangeObject<string>[]) => string;converts a list of change objects to a serialized XML format
function createPatch
createPatch: { ( fileName: string, oldStr: string, newStr: string, oldHeader: string | undefined, newHeader: string | undefined, options: CreatePatchCallbackNonabortable ): undefined; ( fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsAbortable & CreatePatchCallbackOptionAbortable ): undefined; ( fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsNonabortable & CreatePatchCallbackOptionNonabortable ): undefined; ( fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsAbortable ): string; ( fileName: string, oldStr: string, newStr: string, oldHeader?: string, newHeader?: string, options?: CreatePatchOptionsNonabortable ): string;};creates a unified diff patch.
Just like createTwoFilesPatch, but with oldFileName being equal to newFileName.
Parameter fileName
String to be output in the filename section of the patch
Parameter oldStr
Original string value
Parameter newStr
New string value
Parameter oldHeader
Optional additional information to include in the old file header.
Parameter newHeader
Optional additional information to include in the new file header.
function createTwoFilesPatch
createTwoFilesPatch: { ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string | undefined, newHeader: string | undefined, options: CreatePatchCallbackNonabortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsAbortable & CreatePatchCallbackOptionAbortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsNonabortable & CreatePatchCallbackOptionNonabortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: CreatePatchOptionsAbortable ): string; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader?: string, newHeader?: string, options?: CreatePatchOptionsNonabortable ): string;};creates a unified diff patch by first computing a diff with
diffLinesand then serializing it to unified diff format.Parameter oldFileName
String to be output in the filename section of the patch for the removals
Parameter newFileName
String to be output in the filename section of the patch for the additions
Parameter oldStr
Original string value
Parameter newStr
New string value
Parameter oldHeader
Optional additional information to include in the old file header.
Parameter newHeader
Optional additional information to include in the new file header.
function diffArrays
diffArrays: { <T>(oldArr: T[], newArr: T[], options: DiffCallbackNonabortable<T[]>): undefined; <T>( oldArr: T[], newArr: T[], options: DiffArraysOptionsAbortable<T> & CallbackOptionAbortable<T[]> ): undefined; <T>( oldArr: T[], newArr: T[], options: DiffArraysOptionsNonabortable<T> & CallbackOptionNonabortable<T[]> ): undefined; <T>( oldArr: T[], newArr: T[], options: DiffArraysOptionsAbortable<T> ): ChangeObject<T[]>[]; <T>( oldArr: T[], newArr: T[], options?: DiffArraysOptionsNonabortable<T> ): ChangeObject<T[]>[];};diffs two arrays of tokens, comparing each item for strict equality (===).
Returns
a list of change objects.
function diffChars
diffChars: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCharsOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCharsOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCharsOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffCharsOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, treating each character as a token.
("Characters" here means Unicode code points - the elements you get when you loop over a string with a
for ... of ...loop.)Returns
a list of change objects.
function diffCss
diffCss: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCssOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCssOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffCssOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffCssOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, comparing CSS tokens.
Returns
a list of change objects.
function diffJson
diffJson: { ( oldStr: string | object, newStr: string | object, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string | object, newStr: string | object, options: DiffJsonOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string | object, newStr: string | object, options: DiffJsonOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string | object, newStr: string | object, options: DiffJsonOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string | object, newStr: string | object, options?: DiffJsonOptionsNonabortable ): ChangeObject<string>[];};diffs two JSON-serializable objects by first serializing them to prettily-formatted JSON and then treating each line of the JSON as a token. Object properties are ordered alphabetically in the serialized JSON, so the order of properties in the objects being compared doesn't affect the result.
Returns
a list of change objects.
function diffLines
diffLines: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffLinesOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, treating each line as a token.
Returns
a list of change objects.
function diffSentences
diffSentences: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffSentencesOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffSentencesOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffSentencesOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffSentencesOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, treating each sentence, and the whitespace between each pair of sentences, as a token. The characters
.,!, and?, when followed by whitespace, are treated as marking the end of a sentence; nothing else besides the end of the string is considered to mark a sentence end.(For more sophisticated detection of sentence breaks, including support for non-English punctuation, consider instead tokenizing with an [
Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) withgranularity: 'sentence'and passing the result todiffArrays.)Returns
a list of change objects.
function diffTrimmedLines
diffTrimmedLines: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffLinesOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffLinesOptionsNonabortable ): ChangeObject<string>[];};function diffWords
diffWords: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffWordsOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, treating each word and each punctuation mark as a token. Whitespace is ignored when computing the diff (but preserved as far as possible in the final change objects).
Returns
a list of change objects.
function diffWordsWithSpace
diffWordsWithSpace: { ( oldStr: string, newStr: string, options: DiffCallbackNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsAbortable & CallbackOptionAbortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsNonabortable & CallbackOptionNonabortable<string> ): undefined; ( oldStr: string, newStr: string, options: DiffWordsOptionsAbortable ): ChangeObject<string>[]; ( oldStr: string, newStr: string, options?: DiffWordsOptionsNonabortable ): ChangeObject<string>[];};diffs two blocks of text, treating each word, punctuation mark, newline, or run of (non-newline) whitespace as a token.
Returns
a list of change objects
function formatPatch
formatPatch: ( patch: StructuredPatch | StructuredPatch[], headerOptions?: HeaderOptions) => string;creates a unified diff patch.
Parameter patch
either a single structured patch object (as returned by
structuredPatch) or an array of them (as returned byparsePatch).Parameter headerOptions
behaves the same as the
headerOptionsoption ofcreateTwoFilesPatch. Ignored for patches whereisGitistrue.When a patch has
isGit: true,formatPatchoutput is changed to more closely match Git's output: it emits adiff --githeader, emits Git extended headers as appropriate based on properties likeisRename,isCreate,newMode, etc, and will omit---/+++file headers for patches with no hunks (e.g. renames without content changes).
function parsePatch
parsePatch: (uniDiff: string) => StructuredPatch[];Parses a unified diff format patch into a structured patch object.
parsePatchhas some understanding of Git's particular dialect of unified diff format. When parsing a Git patch, each index in the result may contain additional fields (isRename,isBinary, etc) not included in the data structure returned bystructuredPatch; see theStructuredPatchinterface for a full list.a JSON object representation of the patch, suitable for use with the
applyPatchmethod. This parses to the same structure returned bystructuredPatch, except thatoldFileNameandnewFileNamemay beundefinedif the patch doesn't contain enough information to determine them (e.g. a hunk-only patch with no file headers).
function reversePatch
reversePatch: { (structuredPatch: StructuredPatch): StructuredPatch; (structuredPatch: StructuredPatch[]): StructuredPatch[]; (structuredPatch: StructuredPatch | StructuredPatch[]): | StructuredPatch | StructuredPatch[];};Returns a new structured patch which when applied will undo the original
patch.When
patchis a Git-style patch,reversePatchhandles extended header information (relating to renames, file modes, etc.) to the extent that doing so is possible, but note one fundamental limitation: the correct inverse of a patch featuringcopy from/copy toheaders cannot, in general, be determined based on the information contained in the patch alone, and soreversePatch's output when passed such a patch will usually be rejected bygit apply. (The correct inverse would be a patch that deletes the newly-created file, but for Git to apply such a patch, the patch must explicitly delete every line of content in the file too, and that content cannot be determined from the original patch on its own.reversePatchtherefore does the only vaguely reasonable thing it can do in this scenario: it outputs a patch with adeleted file modeheader - indicating that the file should be deleted - but no hunks.)Parameter patch
either a single structured patch object (as returned by
structuredPatch) or an array of them (as returned byparsePatch).
function structuredPatch
structuredPatch: { ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string | undefined, newHeader: string | undefined, options: StructuredPatchCallbackNonabortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: StructuredPatchOptionsAbortable & StructuredPatchCallbackOptionAbortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: StructuredPatchOptionsNonabortable & StructuredPatchCallbackOptionNonabortable ): undefined; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options: StructuredPatchOptionsAbortable ): StructuredPatch; ( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader?: string, newHeader?: string, options?: StructuredPatchOptionsNonabortable ): StructuredPatch;};returns an object with an array of hunk objects.
This method is similar to createTwoFilesPatch, but returns a data structure suitable for further processing.
Parameter oldFileName
String to be output in the filename section of the patch for the removals
Parameter newFileName
String to be output in the filename section of the patch for the additions
Parameter oldStr
Original string value
Parameter newStr
New string value
Parameter oldHeader
Optional additional information to include in the old file header.
Parameter newHeader
Optional additional information to include in the new file header.
Classes
class Diff
class Diff< TokenT, ValueT extends Iterable<TokenT> = Iterable<TokenT>, InputValueT = ValueT> {}property useLongestToken
readonly useLongestToken: boolean;method castInput
castInput: (value: InputValueT, options: AllDiffOptions) => ValueT;method diff
diff: { ( oldStr: InputValueT, newStr: InputValueT, options: DiffCallbackNonabortable<ValueT> ): undefined; ( oldStr: InputValueT, newStr: InputValueT, options: DiffArraysOptions<unknown> & DiffCharsOptions & DiffWordsOptions & DiffLinesOptions & DiffJsonOptions & AbortableDiffOptions & CallbackOptionAbortable<ValueT> ): undefined; ( oldStr: InputValueT, newStr: InputValueT, options: DiffArraysOptions<unknown> & DiffCharsOptions & DiffWordsOptions & DiffLinesOptions & DiffJsonOptions & CallbackOptionNonabortable<ValueT> ): undefined; ( oldStr: InputValueT, newStr: InputValueT, options: DiffArraysOptions<unknown> & DiffCharsOptions & DiffWordsOptions & DiffLinesOptions & DiffJsonOptions & AbortableDiffOptions ): ChangeObject<ValueT>[]; ( oldStr: InputValueT, newStr: InputValueT, options?: AllDiffOptions ): ChangeObject<ValueT>[];};method equals
equals: (left: TokenT, right: TokenT, options: AllDiffOptions) => boolean;method join
join: (chars: TokenT[]) => ValueT;method postProcess
postProcess: ( changeObjects: ChangeObject<ValueT>[], options: AllDiffOptions) => ChangeObject<ValueT>[];method removeEmpty
removeEmpty: (array: TokenT[]) => TokenT[];method tokenize
tokenize: (value: ValueT, options: AllDiffOptions) => TokenT[];Interfaces
interface ApplyPatchesOptions
interface ApplyPatchesOptions extends ApplyPatchOptions {}interface ApplyPatchOptions
interface ApplyPatchOptions {}property autoConvertLineEndings
autoConvertLineEndings?: boolean;If
true, and if the file to be patched consistently uses different line endings to the patch (i.e. either the file always uses Unix line endings while the patch uses Windows ones, or vice versa), thenapplyPatchwill behave as if the line endings in the patch were the same as those in the source file. (Iffalse, the patch will usually fail to apply in such circumstances since lines deleted in the patch won't be considered to match those in the source file.) true
property compareLine
compareLine?: ( lineNumber: number, line: string, operation: string, patchContent: string) => boolean;Callback used to compare to given lines to determine if they should be considered equal when patching. Defaults to strict equality but may be overridden to provide fuzzier comparison. Should return false if the lines should be rejected.
property fuzzFactor
fuzzFactor?: number;Maximum Levenshtein distance (in lines deleted, added, or subtituted) between the context shown in a patch hunk and the lines found in the file. 0
interface ChangeObject
interface ChangeObject<ValueT> {}property added
added: boolean;true if the value was inserted into the new string, otherwise false
property count
count: number;How many tokens (e.g. chars for
diffChars, lines fordiffLines) the value in the change object consists of
property removed
removed: boolean;true if the value was removed from the old string, otherwise false
property value
value: ValueT;The concatenated content of all the tokens represented by this change object - i.e. generally the text that is either added, deleted, or common, as a single string. In cases where tokens are considered common but are non-identical (e.g. because an option like
ignoreCaseor a customcomparatorwas used), the value from the *new* string will be provided here.
interface CreatePatchOptionsNonabortable
interface CreatePatchOptionsNonabortable extends Pick< DiffLinesOptionsNonabortable, 'ignoreWhitespace' | 'stripTrailingCr' > {}property callback
callback?: CreatePatchCallbackNonabortable;property context
context?: number;property headerOptions
headerOptions?: HeaderOptions;interface DiffArraysOptionsNonabortable
interface DiffArraysOptionsNonabortable<T> extends DiffArraysOptions<T> {}property callback
callback?: DiffCallbackNonabortable<T[]>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffCharsOptionsNonabortable
interface DiffCharsOptionsNonabortable extends DiffCharsOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffCssOptionsNonabortable
interface DiffCssOptionsNonabortable extends DiffCssOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffJsonOptionsNonabortable
interface DiffJsonOptionsNonabortable extends DiffJsonOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffLinesOptionsNonabortable
interface DiffLinesOptionsNonabortable extends DiffLinesOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffSentencesOptionsNonabortable
interface DiffSentencesOptionsNonabortable extends DiffSentencesOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface DiffWordsOptionsNonabortable
interface DiffWordsOptionsNonabortable extends DiffWordsOptions {}property callback
callback?: DiffCallbackNonabortable<string>;If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the
callbackoption should be a function and will be passed the computed diff or patch as its first argument.
interface HeaderOptions
interface HeaderOptions {}property includeFileHeaders
includeFileHeaders: boolean;property includeIndex
includeIndex: boolean;property includeUnderline
includeUnderline: boolean;interface StructuredPatch
interface StructuredPatch {}property hunks
hunks: StructuredPatchHunk[];property index
index?: string;property isBinary
isBinary?: boolean;Set to true when parsing a Git diff that includes a
Binary files ... differline, indicating a binary file change. Binary patches have no hunks, so the patch content alone is not sufficient to apply the change; consumers should handle this case specially (e.g. by warning the user or fetching the binary content separately).
property isCopy
isCopy?: boolean;Set to true when parsing a Git diff that includes
copy from/copy toextended headers, indicating the file was copied (and the old file still exists). Consumers applying the patch should NOT delete the old file.
property isCreate
isCreate?: boolean;Set to true when parsing a Git diff that includes a
new file modeextended header, indicating the file was newly created.
property isDelete
isDelete?: boolean;Set to true when parsing a Git diff that includes a
deleted file modeextended header, indicating the file was deleted.
property isGit
isGit?: boolean;Set to true when the patch was parsed from a Git-style diff (one with a
diff --githeader). Controls whetherformatPatchemits adiff --githeader (instead ofIndex:/ underline headers) when formatting the patch.
property isRename
isRename?: boolean;Set to true when parsing a Git diff that includes
rename from/rename toextended headers, indicating the file was renamed (and the old file no longer exists). Consumers applying the patch should delete the old file.
property newFileName
newFileName: string | undefined;property newHeader
newHeader: string | undefined;property newMode
newMode?: string;The file mode (e.g.
'100644','100755') of the new file, parsed from Git extended headers (new modeornew file mode).
property oldFileName
oldFileName: string | undefined;property oldHeader
oldHeader: string | undefined;property oldMode
oldMode?: string;The file mode (e.g.
'100644','100755') of the old file, parsed from Git extended headers (old modeordeleted file mode).
interface StructuredPatchHunk
interface StructuredPatchHunk {}interface StructuredPatchOptionsNonabortable
interface StructuredPatchOptionsNonabortable extends Pick< DiffLinesOptionsNonabortable, 'ignoreWhitespace' | 'stripTrailingCr' > {}Type Aliases
type ArrayChange
type ArrayChange<T> = ChangeObject<T[]>;type Change
type Change = ChangeObject<string>;type CreatePatchOptionsAbortable
type CreatePatchOptionsAbortable = _CreatePatchOptionsAbortable & AbortableDiffOptions;type DiffArraysOptionsAbortable
type DiffArraysOptionsAbortable<T> = DiffArraysOptions<T> & AbortableDiffOptions & Partial<CallbackOptionAbortable<T[]>>;type DiffCharsOptionsAbortable
type DiffCharsOptionsAbortable = DiffCharsOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type DiffCssOptionsAbortable
type DiffCssOptionsAbortable = DiffCssOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type DiffJsonOptionsAbortable
type DiffJsonOptionsAbortable = DiffJsonOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type DiffLinesOptionsAbortable
type DiffLinesOptionsAbortable = DiffLinesOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type DiffSentencesOptionsAbortable
type DiffSentencesOptionsAbortable = DiffSentencesOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type DiffWordsOptionsAbortable
type DiffWordsOptionsAbortable = DiffWordsOptions & AbortableDiffOptions & Partial<CallbackOptionAbortable<string>>;type StructuredPatchOptionsAbortable
type StructuredPatchOptionsAbortable = _StructuredPatchOptionsAbortable & AbortableDiffOptions;Package Files (16)
- libcjs/convert/dmp.d.ts
- libcjs/convert/xml.d.ts
- libcjs/diff/array.d.ts
- libcjs/diff/base.d.ts
- libcjs/diff/character.d.ts
- libcjs/diff/css.d.ts
- libcjs/diff/json.d.ts
- libcjs/diff/line.d.ts
- libcjs/diff/sentence.d.ts
- libcjs/diff/word.d.ts
- libcjs/index.d.ts
- libcjs/patch/apply.d.ts
- libcjs/patch/create.d.ts
- libcjs/patch/parse.d.ts
- libcjs/patch/reverse.d.ts
- libcjs/types.d.ts
Dependencies (0)
No dependencies.
Dev Dependencies (26)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/diff.
- Markdown[](https://www.jsdocs.io/package/diff)
- HTML<a href="https://www.jsdocs.io/package/diff"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5097 ms. - Missing or incorrect documentation? Open an issue for this package.
