diff --git a/src/render-utils.ts b/src/render-utils.ts index cf91361..d93f587 100644 --- a/src/render-utils.ts +++ b/src/render-utils.ts @@ -4,14 +4,22 @@ import { unifyPath, hashCode } from './utils'; import * as rematch from './rematch'; import { LineMatchingType, DiffStyleType, LineType, DiffLineParts, DiffFile, DiffFileName } from './types'; -export enum 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 CSSLineClass = + | 'd2h-ins' + | 'd2h-del' + | 'd2h-cntx' + | 'd2h-info' + | 'd2h-ins 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 = { oldLine: { diff --git a/src/types.ts b/src/types.ts index a7515f7..d573ac9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -69,18 +69,24 @@ export interface DiffFile extends DiffFileName { mode?: string; } -export enum OutputFormatType { - LINE_BY_LINE = 'line-by-line', - SIDE_BY_SIDE = 'side-by-side', -} +export type OutputFormatType = 'line-by-line' | 'side-by-side'; -export enum LineMatchingType { - LINES = 'lines', - WORDS = 'words', - NONE = 'none', -} +export const OutputFormatType: { [_: string]: OutputFormatType } = { + LINE_BY_LINE: 'line-by-line', + SIDE_BY_SIDE: 'side-by-side', +}; -export enum DiffStyleType { - WORD = 'word', - CHAR = 'char', -} +export type LineMatchingType = 'lines' | 'words' | 'none'; + +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', +};