Closed
Description
Mutative v0.3.2 does not fully support the JSON Patch spec.
path
type is an array, not a string as defined in the JSON patch spec.- The patches generated by Mutative array clearing are a modification of the array
length
, which is not consistent with JSON Patch spec. - Need to support JSON Pointer spec.
Since standard JSON patches are often used to sync backend with front-end state, compliance with JSON patch standard is necessary. However, considering array clearing patches will bring predictable performance loss, and has path
type conversion issues.
We propose to add the option usePatches: 'json-patch' | 'never' | 'always'
, with the default value of never
, and remove enablePatches
.
- If the option
usePatches
isalways
, the patches it produces will not exactly match JSON patch spec, but it will maintain the good performance that most uses of patches require. - If the option
usePatches
isjson-patch
, it produces patches that will be fully compliant with JSON patch spec, which has a slight performance penalty, and it ensures that the data it produces can be passed to other backend APIs based on JSON patch spec.