imevro / redux-diff-logger

Diff logger between states for redux
http://fcomb.github.io/redux-diff-logger/
175 stars 15 forks source link

Show result for all possible diffs #1

Open i4got10 opened 9 years ago

i4got10 commented 9 years ago

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

2015-08-10_1848

imevro commented 9 years ago

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

i4got10 commented 9 years ago

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.

imevro commented 9 years ago

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 commented 9 years ago

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' } } }
ericclemmons commented 9 years ago

"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)

imevro commented 9 years ago

@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.

ericclemmons commented 9 years ago

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!

smashercosmo commented 8 years ago

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