There is a bug in diffApply function from just-diff-apply package
import { diff } from 'just-diff'
import { diffApply } from 'just-diff-apply'
const source = { a: [ 1, 2, 3, 4, 5 ] }
const newSource = { a: [ 1, 2, 5 ] }
const changes = diff(source, newSource) // [{ op: 'remove', path: ['a', 4] }, { op: 'remove', path: ['a', 3] }, { op: 'replace', path: ['a', 2], value: 5 }]
console.log(changes)
// Expected value is newSource, but got only the array [1, 2, 5]
const appliedChanges = diffApply(source, changes) // [1, 2, 5]
console.log(appliedChanges)
If I replace return subObject in diffApply function with return obj I will get correct result
There is a bug in diffApply function from just-diff-apply package
If I replace
return subObjectin diffApply function withreturn objI will get correct result