mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add additional patch methods in jsdiff
* Add `IUniDiff` struct, representing a unified diff * Add `IHunk` struct, representing a section of modified lines and context * Fix `createPatch` optional `options` argument * Fix `applyPatch` to accept either a patch string, IUniDiff or IUniDiff array * Add `createTwoFilesPatch`, `structuredPatch` and `applyPatches` * Add test code for these new functions
This commit is contained in:
Vendored
+30
-2
@@ -16,6 +16,22 @@ declare namespace JsDiff {
|
||||
componenets: IDiffResult[];
|
||||
}
|
||||
|
||||
interface IHunk {
|
||||
oldStart: number;
|
||||
oldLines: number;
|
||||
newStart: number;
|
||||
newLines: number;
|
||||
lines: string[];
|
||||
}
|
||||
|
||||
interface IUniDiff {
|
||||
oldFileName: string;
|
||||
newFileName: string;
|
||||
oldHeader: string;
|
||||
newHeader: string;
|
||||
hunks: IHunk[];
|
||||
}
|
||||
|
||||
class Diff {
|
||||
ignoreWhitespace:boolean;
|
||||
|
||||
@@ -46,9 +62,21 @@ declare namespace JsDiff {
|
||||
|
||||
function diffCss(oldStr:string, newStr:string):IDiffResult[];
|
||||
|
||||
function createPatch(fileName:string, oldStr:string, newStr:string, oldHeader:string, newHeader:string):string;
|
||||
function createPatch(fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function applyPatch(oldStr:string, uniDiff:string):string;
|
||||
function createTwoFilesPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function structuredPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): IUniDiff;
|
||||
|
||||
function applyPatch(oldStr: string, uniDiff: string | IUniDiff | IUniDiff[]): string;
|
||||
|
||||
function applyPatches(uniDiff: IUniDiff[], options: {
|
||||
loadFile: (index: number, callback: (err: Error, data: string) => void) => void,
|
||||
patched: (index: number, content: string) => void,
|
||||
complete: (err?: Error) => void
|
||||
}): void;
|
||||
|
||||
function parsePatch(diffStr: string, options?: {strict: boolean}): IUniDiff[];
|
||||
|
||||
function convertChangesToXML(changes:IDiffResult[]):string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user