JSONPatcherProxy
JSONPatcherProxy copied to clipboard
Inconsistent patch generation when adding `undefined` elements to an array
This is a continuation of dicussion here: https://github.com/Palindrom/JSONPatcherProxy/pull/45#discussion_r311897775
Steps to reproduce
See failing test here: 7cf32fd09593fef2751abc51114267e4a14f3897
The test extends an array with 5 elements to 9 elements with undefined
or null
values.
Expected result
Four add
patches to add null
elements.
Actual result
One add
patch and one replace
patch.
I decided to implement the solution in the already opened PR https://github.com/Palindrom/JSONPatcherProxy/pull/45, because I was afraid of creating a conflict that's troublesome to merge.
This issue is partially solved in #45, but there are even more edge cases:
There are 3 kinds of arrays to test:
- array of values other than
undefined
- array of
undefined
- of empty slots (https://stackoverflow.com/questions/40752434/how-to-tell-between-undefined-array-elements-and-empty-slots/40752485)
There are many kinds of array operations to test:
- array.shift()
- array.pop()
- array.unshift()
- array.push()
- array.splice()
- array.length