Skip to content

array "-" patches are inserting at beginning instead of appending to the end #897

@bradedelman

Description

@bradedelman

const state0 = {a: []};
const state1 = applyPatches(state0, [{op: "add", path: ["a","-"], value: 1}]);
const state2 = applyPatches(state1, [{op: "add", path: ["a","-"], value: 2}]);
const state3 = applyPatches(state2, [{op: "add", path: ["a","-"], value: 3}]);
console.log(state3);

per the JSON patch spec should produce state3 as:
{ a: [ 1, 2, 3 ] }

however, Immer produces state3 as:
{ a: [ 3, 2, 1 ] }

this is wrong. Immer is inserting at beginning instead of appending to the end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions