forked from kpdecker/jsdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss.ts
More file actions
44 lines (41 loc) · 1.27 KB
/
Copy pathcss.ts
File metadata and controls
44 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Diff from './base.js';
import type { ChangeObject, CallbackOptionAbortable, CallbackOptionNonabortable, DiffCallbackNonabortable, DiffCssOptionsAbortable, DiffCssOptionsNonabortable} from '../types.js';
class CssDiff extends Diff<string, string> {
tokenize(value: string) {
return value.split(/([{}:;,]|\s+)/);
}
}
export const cssDiff = new CssDiff();
/**
* diffs two blocks of text, comparing CSS tokens.
*
* @returns a list of change objects.
*/
export function diffCss(
oldStr: string,
newStr: string,
options: DiffCallbackNonabortable<string>
): undefined;
export function diffCss(
oldStr: string,
newStr: string,
options: DiffCssOptionsAbortable & CallbackOptionAbortable<string>
): undefined
export function diffCss(
oldStr: string,
newStr: string,
options: DiffCssOptionsNonabortable & CallbackOptionNonabortable<string>
): undefined
export function diffCss(
oldStr: string,
newStr: string,
options: DiffCssOptionsAbortable
): ChangeObject<string>[] | undefined
export function diffCss(
oldStr: string,
newStr: string,
options?: DiffCssOptionsNonabortable
): ChangeObject<string>[]
export function diffCss(oldStr: string, newStr: string, options?: any): undefined | ChangeObject<string>[] {
return cssDiff.diff(oldStr, newStr, options);
}