Skip to content

Commit

Permalink
fix: Make Diff#inspect() output more readable
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed May 16, 2024
1 parent 5db36fb commit f63e61d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/Diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ export default class Diff {
return batches
}

inspect(): Action[] {
return this.getActions()
}

/**
* on ServerToLocal: don't map removals
* on LocalToServer:
Expand Down Expand Up @@ -281,6 +277,12 @@ export default class Diff {
})
}

inspect(depth = 0):string {
return 'Diff\n' + this.getActions().map((action: Action) => {
return `\nAction: ${action.type}\nPayload: ${action.payload.inspect()}${'index' in action ? `Index: ${action.index}\n` : ''}${'order' in action ? `Order: ${JSON.stringify(action.order, null, '\t')}` : ''}`
}).join('\n')
}

static fromJSON(json) {
const diff = new Diff
json.forEach((action: Action): void => {
Expand Down

0 comments on commit f63e61d

Please sign in to comment.