Skip to content

compare on arrays produces an unexpected UNCHANGED entry #358

@YoungFrog

Description

@YoungFrog

Consider the following :

import { compare } from 'json-diff-ts'

console.log(compare(["foo"], ["bar"]))

The result is :

{
type: 'CONTAINER',
value: [ { type: 'UNCHANGED', value: 'foo' }, '$root': [ [Object] ] ]
}

(the actual change is hidden inside the $root key) Is this intended ?

It seems inconsistent with what happens for objects :

import { compare } from 'json-diff-ts'

console.log(compare({ "k": "foo" }, { "k": "bar" }))

{
type: 'CONTAINER',
value: { k: { type: 'UPDATE', value: 'bar', oldValue: 'foo' } }
}

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