3 ms·
We built a similar JavaScript library to create and apply JSON patches: https://github.com/Two-Screen/symmetry https://github.com/Two-Screen/symmetry The forma
by kosinus 12y ago
We built a similar JavaScript library to create and apply JSON patches: https://github.com/Two-Screen/symmetry https://github.com/Two-Screen/symmetry
The format is not formally specified in any way, but it looks like the biggest differences are that we 1) make a distinction between object and array operations and 2) don't encode paths, but instead nest patches.
In practice, we found our JSON structures are never deep enough for nesting to a problem. To save space on the wire, our patch object has single character keys, such as `s` for set, `r` for remove, etc.
It looks like these libraries don't actually create patches? Symmetry has routines to diff between two objects, and implements Myers' algorithm for array comparisons. (Already fast, but can be further optimized.)
On the other hand, Symmetry doesn't have copy, move or test operations. Those are interesting.