[BUG]generate error patch document when object has Date field
fissssssh opened this issue · comments
fissssssh commented
i wrote this code:
const obj = { date1: new Date(), date2: new Date() };
const observer = jsonpatch.observe<any>(obj);
const patchDoc = jsonpatch.generate(observer);
console.log(patchDoc);
observer.unobserve();
and then output:
[
{
"op": "replace",
"path": "/date2",
"value": "2021-04-16T14:11:13.382Z"
},
{
"op": "replace",
"path": "/date1",
"value": "2021-04-16T14:11:13.382Z"
}
]
absolutly i didn't do anythiny but there are two patches,
so i view the source code found the error
file: src/duplex.ts line:128
_generate(mirror.value, observer.object, observer.patches, "", invertible);
should use mirror.obj
instead mirror.value
please fix it as soon as possible.
Vladimir Venegas Velásquez commented
We have the same issue. Any plans to fix it?
fissssssh commented
We have the same issue. Any plans to fix it?
replace Date with Unix Timestamp (long)
Tim Arnold commented
Is there a fork on npm fixing this issue?