TehShrike/deepmerge

customMerge on constructor

xenoterracide opened this issue · 1 comments

I want to merge a @js-joda/core type, these apparently can't be cloned simply by value... so I'm looking at customMerge, but I realize I'll more or less have to write it for every key... I mean, I can do some functional magic... What I'd really like to do, is have some kind of a check function that could work on the constructor, and then run the custom merge.

maybe something like

mergers:[ {
    should( key, x, y ): boolean,
    merge( x, y ): unknown
}]

this way the algorithm will just continue if should returns false

in this case all I really want is to return right if defined, and left if not, since these are immutable value objects no need to try to do a special copy.

This sounds like it overlaps with #184 and #176 – how do the solutions proposed in those threads sound to you?