In #10 the revert property would be a valid JSON patch but it comes with a cost.
With this, we don't break the API, the revert property is still not a valid JSON patch but can be transformed to it easily using buildPatchFromRevert
var doc = {foo: 'bar'}
var patch = [...]
var patching = ooPatch.apply(doc, patch, {reversible: true})
doc = patching.doc
//
// know you can revert 2 different ways
//
// the old way
doc = ooPatch.revert(doc, patching.revert)
// OR
// the new way - ideal for packing/unpacking, saving, ...
var revertPatch = ooPatch.buildPatchFromRevert(patching.revert) // valid JSON Patch
doc = ooPatch.apply(doc, revertPatch)
This looks like a big patch it can be resumed to rename foo method to 'buildPatchFromRevert` and export it. The rest is documentation and moving code around for better clarity and smaller builds.
Better alternative to https://github.com/JSON8/patch/pull/10
In #10 the revert property would be a valid JSON patch but it comes with a cost. With this, we don't break the API, the revert property is still not a valid JSON patch but can be transformed to it easily using
buildPatchFromRevert
This looks like a big patch it can be resumed to rename foo method to 'buildPatchFromRevert` and export it. The rest is documentation and moving code around for better clarity and smaller builds.