Closed
Description
<script>
import diff from "microdiff";
const array1 = [1];
const array2 = [2];
const obj1 = {0:1};
const obj2 = {0:2};
</script>
{JSON.stringify(diff(array1,array2))}
<br/>
{JSON.stringify(diff(obj1,obj2))}
Both diffs give the same result, which could be problematic:
[{"path":["0"],"type":"CHANGE","value":2}]
[{"path":["0"],"type":"CHANGE","value":2}]
(repl)
My proposal is to differenciate between object and array by having array indexes be a number instead of a string, so that the result would be this instead:
[{"path":[0],"type":"CHANGE","value":2}]
[{"path":["0"],"type":"CHANGE","value":2}]
So the path array will have this type:
Array<string | number>
This would make it easier to create a patching function too
Metadata
Metadata
Assignees
Labels
No labels