redux-diff-logger icon indicating copy to clipboard operation
redux-diff-logger copied to clipboard

Show result for all possible diffs

Open i4got10 opened this issue 9 years ago • 8 comments

For example, arrays diff looks like undefined "zones.items" undefined " → " undefined right now(then items was appended to collection)

2015-08-10_1848

i4got10 avatar Aug 10 '15 13:08 i4got10

Oh, right, need better support for array. Will fix asap.

imevro avatar Aug 10 '15 17:08 imevro

It would be very good if you will set some test environment and make some tests. It can help other people to send PRs to help you and test your code in isolation.

i4got10 avatar Aug 11 '15 12:08 i4got10

I experimenting, but deep-diff has a little bit weird array support. For example, it shows new & deleted as nested DeepDiff (and it's very handy), but change looks like object change and it's not good. image

I will investigate tomorrow, but I released 0.5.0 with better (than nothing) support for arrays.

imevro avatar Aug 11 '15 22:08 imevro

Good news. I found recursive-diff which works very good (but has 1 small bug, representing nested object as [Object], not actually object). Will release 0.1.0 today.

➜  differs  babel-node index.js
s.plain.object, s.authToken { '/token': { operation: 'add', right: '123' } }
s.authToken, s.authToken2 { '/token': { operation: 'update', left: '123', right: '321dawdaw' } }
s.authToken2, s.authInfo { '/token': { operation: 'delete', left: '321dawdaw' },
  '/id': { operation: 'add', right: '1' },
  '/nickname': { operation: 'add', right: 'theaqua' } }
s.plain.object, s.authInfo { '/id': { operation: 'add', right: '1' },
  '/nickname': { operation: 'add', right: 'theaqua' } }
s.authInfo, s.authInfo2 { '/id': { operation: 'update', left: '1', right: '2' },
  '/nickname': { operation: 'delete', left: 'theaqua' } }
s.plain.array, s.properties { '/0':
   { operation: 'add',
     right: { id: 1, name: 'house', objectProperty: [Object] } },
  '/1': { operation: 'add', right: { id: 2, name: 'townhouse' } },
  '/2': { operation: 'add', right: { id: 3, name: 'flat' } } }
s.properties, s.properties2 { '/0/id': { operation: 'update', left: 1, right: 4 },
  '/0/name': { operation: 'update', left: 'house', right: 'townhouse' },
  '/0/objectProperty/pool':
   { operation: 'update',
     left: { has: true, height: 2 },
     right: false },
  '/0/objectProperty/area': { operation: 'update', left: 101, right: 2 },
  '/1/id': { operation: 'update', left: 2, right: 5 },
  '/1/name': { operation: 'update', left: 'townhouse', right: 'flat' },
  '/2': { operation: 'delete', left: { id: 3, name: 'flat' } } }
s.properties2, s.plain.array { '/0':
   { operation: 'delete',
     left: { id: 4, name: 'townhouse', objectProperty: [Object] } },
  '/1': { operation: 'delete', left: { id: 5, name: 'flat' } } }

imevro avatar Aug 12 '15 05:08 imevro

"today" :D As a fellow OSS author, I know how off time estimates can be.

(great work on https://github.com/fcomb/redux-logger btw)

ericclemmons avatar Oct 21 '15 05:10 ericclemmons

@ericclemmons oh, yes, I tried to build correct implementation but haven't enough time for this :( I hope I will return ASAP to this module.

imevro avatar Oct 21 '15 11:10 imevro

Diff stuff is hard :) There are two libs that I've referenced for solving this problem:

  1. https://github.com/benjamine/jsondiffpatch
  2. https://github.com/flitbit/diff

Hopefully one of those may help!

ericclemmons avatar Oct 21 '15 14:10 ericclemmons

@theaqua any luck with this issue? jsondiffpatch looks very promissing

smashercosmo avatar Nov 16 '15 09:11 smashercosmo