A simplified diff/patch solution learning from immutable-diff/patch.
Values are compared with identical?
for performace in special scenarios.
There's still much room for optimizations in vector diffing.
[cumulo/shallow-diff "0.1.3"]
(shallow-diff.diff/diff x1 x2)
(shallow-diff.patch/patch x1 operations)
Only hash-map
, hash-set
, vector
are supported.
For other types of primitives, it generates set!
to replace.
Format [coord [op arg1 args2]]
, examples:
[[1 ] [:add 2 "x"]]
[[:map] [:remove 1 ]]
For values:
[:set! a-val]
For hash maps:
[:add a-key a-val]
[:drop a-key ]
For vectors:
[:insert a-key a-val]
[:remove a-key ]
[:append a-val ]
For hash sets:
[:include a-val]
[:exclude a-val]
lumo -Kc $boot_deps:src/ -i test/diff.cljs
lumo -Kc $boot_deps:src/ -i test/patch.cljs
lumo -Kc $boot_deps:src/ -i test/round_trip.cljs
https://github.com/mvc-works/stack-workflow
MIT