mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Move all packages to a types directory
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
|
||||
import DiffMatchPatch = require("diff-match-patch");
|
||||
|
||||
var oldValue = "hello world, how are you?";
|
||||
var newValue = "hello again world. how have you been?";
|
||||
|
||||
var diffEngine = new DiffMatchPatch.diff_match_patch();
|
||||
var diffs = diffEngine.diff_main(oldValue, newValue);
|
||||
diffEngine.diff_cleanupSemantic(diffs);
|
||||
|
||||
var changes = "";
|
||||
var pattern = "";
|
||||
|
||||
diffs.forEach(function(diff) {
|
||||
var operation = diff[0]; // Operation (insert, delete, equal)
|
||||
var text = diff[1]; // Text of change
|
||||
|
||||
switch (operation) {
|
||||
case DiffMatchPatch.DIFF_INSERT:
|
||||
pattern += "I";
|
||||
break;
|
||||
case DiffMatchPatch.DIFF_DELETE:
|
||||
pattern += "D";
|
||||
break;
|
||||
case DiffMatchPatch.DIFF_EQUAL:
|
||||
pattern += "E";
|
||||
break;
|
||||
}
|
||||
|
||||
changes += text;
|
||||
});
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// Type definitions for diff-match-patch v1.0.0
|
||||
// Project: https://www.npmjs.com/package/diff-match-patch
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
type Diff = [number, string];
|
||||
|
||||
export declare class Patch {
|
||||
diffs: Diff[];
|
||||
start1: number;
|
||||
start2: number;
|
||||
length1: number;
|
||||
length2: number;
|
||||
}
|
||||
|
||||
export declare class diff_match_patch {
|
||||
static new(): diff_match_patch;
|
||||
|
||||
Diff_Timeout: number;
|
||||
Diff_EditCost: number;
|
||||
Match_Threshold: number;
|
||||
Match_Distance: number;
|
||||
Patch_DeleteThreshold: number;
|
||||
Patch_Margin: number;
|
||||
Match_MaxBits: number;
|
||||
|
||||
diff_main(text1: string, text2: string, opt_checklines?: boolean, opt_deadline?: number): Diff[];
|
||||
diff_commonPrefix(text1: string, text2: string): number;
|
||||
diff_commonSuffix(text1: string, text2: string): number;
|
||||
diff_cleanupSemantic(diffs: Diff[]): void;
|
||||
diff_cleanupSemanticLossless(diffs: Diff[]): void;
|
||||
diff_cleanupEfficiency(diffs: Diff[]): void;
|
||||
diff_cleanupMerge(diffs: Diff[]): void;
|
||||
diff_xIndex(diffs: Diff[], loc: number): number;
|
||||
diff_prettyHtml(diffs: Diff[]): string;
|
||||
diff_text1(diffs: Diff[]): string;
|
||||
diff_text2(diffs: Diff[]): string;
|
||||
diff_levenshtein(diffs: Diff[]): number;
|
||||
diff_toDelta(diffs: Diff[]): string;
|
||||
diff_fromDelta(text1: string, delta: string): Diff[];
|
||||
|
||||
patch_make(text1: any, text2?: string): Patch[];
|
||||
patch_deepCopy(patches: Patch[]): Patch[];
|
||||
patch_apply(patches: Patch[], text: string): [string, boolean[]];
|
||||
patch_fromText(text: string): Patch[];
|
||||
patch_toText(patches: Patch[]): string;
|
||||
}
|
||||
|
||||
export declare var DIFF_DELETE: number;
|
||||
export declare var DIFF_INSERT: number;
|
||||
export declare var DIFF_EQUAL: number;
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"diff-match-patch-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user