Skip to content

Commit f63e61d

Browse files
committed
fix: Make Diff#inspect() output more readable
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 5db36fb commit f63e61d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/Diff.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,6 @@ export default class Diff {
189189
return batches
190190
}
191191

192-
inspect(): Action[] {
193-
return this.getActions()
194-
}
195-
196192
/**
197193
* on ServerToLocal: don't map removals
198194
* on LocalToServer:
@@ -281,6 +277,12 @@ export default class Diff {
281277
})
282278
}
283279

280+
inspect(depth = 0):string {
281+
return 'Diff\n' + this.getActions().map((action: Action) => {
282+
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')}` : ''}`
283+
}).join('\n')
284+
}
285+
284286
static fromJSON(json) {
285287
const diff = new Diff
286288
json.forEach((action: Action): void => {

0 commit comments

Comments
 (0)