Merge pull request #18224 from djrenren/fast-diff

Add types for fast-diff package
This commit is contained in:
Wesley Wigham
2017-07-19 17:40:52 -07:00
committed by GitHub
4 changed files with 55 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import fastDiff = require('fast-diff');
let diffs: fastDiff.Diff[];
diffs = fastDiff("hi there", "hi");
diffs = fastDiff("hi there", "hi", 1);
diffs.forEach((diff: fastDiff.Diff) => {
const operation: number = diff[0];
const text: string = diff[1];
switch (diff[0]) {
case fastDiff.EQUAL: break;
case fastDiff.DELETE: break;
case fastDiff.INSERT: break;
}
});
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for fast-diff 1.1
// Project: https://github.com/jhchen/fast-diff#readme
// Definitions by: John Renner <https://github.com/djrenren>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function diff(text1: string, text2: string, cursorPos?: number): diff.Diff[];
declare namespace diff {
type Diff = [-1 | 0 | 1, string];
const DELETE: -1;
const INSERT: 1;
const EQUAL: 0;
}
export = diff;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fast-diff-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }