Thanks to visit codestin.com
Credit goes to github.com

Skip to content

diffApply array bug #590

@letzabelin

Description

@letzabelin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions