Skip to content

Commit fe8365b

Browse files
committed
clean: Replace enums with string or type and object
1 parent e772b26 commit fe8365b

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

src/render-utils.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import { unifyPath, hashCode } from './utils';
44
import * as rematch from './rematch';
55
import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types';
66

7-
export enum CSSLineClass {
8-
INSERTS = 'd2h-ins',
9-
DELETES = 'd2h-del',
10-
CONTEXT = 'd2h-cntx',
11-
INFO = 'd2h-info',
12-
INSERT_CHANGES = 'd2h-ins d2h-change',
13-
DELETE_CHANGES = 'd2h-del d2h-change',
14-
}
7+
export type CSSLineClass =
8+
| 'd2h-ins'
9+
| 'd2h-del'
10+
| 'd2h-cntx'
11+
| 'd2h-info'
12+
| 'd2h-ins d2h-change'
13+
| 'd2h-del d2h-change';
14+
15+
export const CSSLineClass: { [_: string]: CSSLineClass } = {
16+
INSERTS: 'd2h-ins',
17+
DELETES: 'd2h-del',
18+
CONTEXT: 'd2h-cntx',
19+
INFO: 'd2h-info',
20+
INSERT_CHANGES: 'd2h-ins d2h-change',
21+
DELETE_CHANGES: 'd2h-del d2h-change',
22+
};
1523

1624
export type HighlightedLines = {
1725
oldLine: {

src/types.ts

+19-13
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,24 @@ export interface DiffFile extends DiffFileName {
6969
mode?: string;
7070
}
7171

72-
export enum OutputFormatType {
73-
LINE_BY_LINE = 'line-by-line',
74-
SIDE_BY_SIDE = 'side-by-side',
75-
}
72+
export type OutputFormatType = 'line-by-line' | 'side-by-side';
7673

77-
export enum LineMatchingType {
78-
LINES = 'lines',
79-
WORDS = 'words',
80-
NONE = 'none',
81-
}
74+
export const OutputFormatType: { [_: string]: OutputFormatType } = {
75+
LINE_BY_LINE: 'line-by-line',
76+
SIDE_BY_SIDE: 'side-by-side',
77+
};
8278

83-
export enum DiffStyleType {
84-
WORD = 'word',
85-
CHAR = 'char',
86-
}
79+
export type LineMatchingType = 'lines' | 'words' | 'none';
80+
81+
export const LineMatchingType: { [_: string]: LineMatchingType } = {
82+
LINES: 'lines',
83+
WORDS: 'words',
84+
NONE: 'none',
85+
};
86+
87+
export type DiffStyleType = 'word' | 'char';
88+
89+
export const DiffStyleType: { [_: string]: DiffStyleType } = {
90+
WORD: 'word',
91+
CHAR: 'char',
92+
};

0 commit comments

Comments
 (0)