Open itsdarrylnorris opened 4 years ago
The current version of deepmerge is still using this naive object detection (typeof new Set()
returns 'object'
).
You probably want to pass is-plain-obj
in to isMergeableObject
, per this part of the readme.
This will cause the set to be used directly on the new object (not cloned).
Related: #152 which is fixed in the v5 branch
Can also use Array.from(#set) to get an array and then pass to deepmerge. #TehSrike do you suggest doing it in the library?
@Gaurav2048 are you asking about having the library automatically convert sets to arrays? If so I don't think this should be supported as that would change the structure of the resulting object. I opened another issue (#204) a little while ago for handling Set
and Map
merging.
If you want that kind of behavior, you would probably want to use klona
in your customMerge
function.
@TehShrike I think it might be worth having a customClone
option in addition to the customMerge
option. This library's current built in clone method fails when it tries to clone non plain objects. The option would also address the concerns raised in #163.
There might be traps in there somewhere but my initial reaction is that makes sense to me
Problem
I am running into a problem using the JavaScript Set function that after merging two objects for some reason it's not keeping the array from set.
Here is the code:
Output:
Solution
We need to keep values from set. The output should looks like this: