mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for fast-diff
This commit is contained in:
parent
d2bf223394
commit
2a92293a59
16
types/fast-diff/fast-diff-tests.ts
Normal file
16
types/fast-diff/fast-diff-tests.ts
Normal 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.DIFF_EQUAL: break;
|
||||
case fastDiff.DIFF_DELETE: break;
|
||||
case fastDiff.DIFF_INSERT: break;
|
||||
}
|
||||
});
|
||||
16
types/fast-diff/index.d.ts
vendored
Normal file
16
types/fast-diff/index.d.ts
vendored
Normal 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 DIFF_DELETE: -1;
|
||||
const DIFF_INSERT: 1;
|
||||
const DIFF_EQUAL: 0;
|
||||
}
|
||||
|
||||
export = diff;
|
||||
22
types/fast-diff/tsconfig.json
Normal file
22
types/fast-diff/tsconfig.json
Normal 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
types/fast-diff/tslint.json
Normal file
1
types/fast-diff/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user