clean: Replace enums with string or type and object

This commit is contained in:
Rodrigo Fernandes 2020-01-25 23:49:17 +00:00
parent e772b26d1c
commit fe8365bcc1
No known key found for this signature in database
GPG key ID: 67157D2E3D4258B4
2 changed files with 35 additions and 21 deletions

View file

@ -4,14 +4,22 @@ import { unifyPath, hashCode } from './utils';
import * as rematch from './rematch'; import * as rematch from './rematch';
import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types'; import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types';
export enum CSSLineClass { export type CSSLineClass =
INSERTS = 'd2h-ins', | 'd2h-ins'
DELETES = 'd2h-del', | 'd2h-del'
CONTEXT = 'd2h-cntx', | 'd2h-cntx'
INFO = 'd2h-info', | 'd2h-info'
INSERT_CHANGES = 'd2h-ins d2h-change', | 'd2h-ins d2h-change'
DELETE_CHANGES = 'd2h-del d2h-change', | 'd2h-del d2h-change';
}
export const CSSLineClass: { [_: string]: CSSLineClass } = {
INSERTS: 'd2h-ins',
DELETES: 'd2h-del',
CONTEXT: 'd2h-cntx',
INFO: 'd2h-info',
INSERT_CHANGES: 'd2h-ins d2h-change',
DELETE_CHANGES: 'd2h-del d2h-change',
};
export type HighlightedLines = { export type HighlightedLines = {
oldLine: { oldLine: {

View file

@ -69,18 +69,24 @@ export interface DiffFile extends DiffFileName {
mode?: string; mode?: string;
} }
export enum OutputFormatType { export type OutputFormatType = 'line-by-line' | 'side-by-side';
LINE_BY_LINE = 'line-by-line',
SIDE_BY_SIDE = 'side-by-side',
}
export enum LineMatchingType { export const OutputFormatType: { [_: string]: OutputFormatType } = {
LINES = 'lines', LINE_BY_LINE: 'line-by-line',
WORDS = 'words', SIDE_BY_SIDE: 'side-by-side',
NONE = 'none', };
}
export enum DiffStyleType { export type LineMatchingType = 'lines' | 'words' | 'none';
WORD = 'word',
CHAR = 'char', export const LineMatchingType: { [_: string]: LineMatchingType } = {
} LINES: 'lines',
WORDS: 'words',
NONE: 'none',
};
export type DiffStyleType = 'word' | 'char';
export const DiffStyleType: { [_: string]: DiffStyleType } = {
WORD: 'word',
CHAR: 'char',
};