json0-ot-diff
json0-ot-diff copied to clipboard
Could support object array item move?
Every item has an uuid, like
[{ id: 1 }, { id: 2 }, { id: 3 } ]
if move item idx.3 to idx.2 ,then looks like:
[{ id: 1 }, { id: 3 }, { id: 2 } ]
diff should produce
[ [ 1, { p: 0 } ], [ 2, { d: 0 } ] ]
and:
{
a: [{ id: 1 }, { id: 2 }, { id: 3 }],
b: [{ id: 4 }]
}
move a.idx2 to b, just like:
{
a: [{ id: 1 }, { id: 3 }],
b: [{ id: 2 }, { id: 4 }]
}
diff should produce
[ [ 'a', 1, { p: 0 } ], [ 'b', 0, { d: 0 } ] ]
Awesome! Would you be able to add a failing unit test? That would help immensely in implementing this.
Awesome! Would you be able to add a failing unit test? That would help immensely in implementing this.
I think first diff api should support a parameters to specifiy which key is uuid, am i right?
just like https://github.com/benjamine/jsondiffpatch which support objectHash function parameter
I suppose that API definition could come from the unit test. I like test-driven development, where first we show what we want to invocation to look like, then build support for that test.