Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ export interface HtmlFormatter extends Formatter {
hideUnchanged(node?: Element | null, delay?: number): void;
}

type AddOperation = {
opp: string;
Copy link
Collaborator

@Methuselah96 Methuselah96 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these should be op and not opp (on all the operations)?

path: string;
value: any
}

type RemoveOperation = {
opp: string;
path: string;
}

type ReplaceOperation = {
opp: string;
path: string;
value: any;
}

type MoveOperation = {
opp: string;
path: string;
}

export type Operation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation

export interface JSONPatchFormatter {
Copy link
Collaborator

@Methuselah96 Methuselah96 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally JSONPatchFormatter would inherit from Formatter, but we can handle that in a future PR.

format(delta: Delta, original: any): Operation[];
}

export interface Delta {
[key: string]: any;
[key: number]: any;
Expand Down Expand Up @@ -190,6 +218,7 @@ export const formatters: {
annotated: Formatter;
console: Formatter;
html: HtmlFormatter;
jsonpatch: JSONPatchFormatter;
};

export const console: Formatter
Expand Down