angus-c / angus-c/just

diffApply array bug

Aperta
#590 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
6.2k
Fork
209
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

There is a bug in diffApply function from just-diff-apply package

```js
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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.