moderndash icon indicating copy to clipboard operation
moderndash copied to clipboard

Feature request - `mergeWith`

Open JustinMartinDev opened this issue 1 year ago • 3 comments

Hello

I would like to know, if you planning to create a mergeWith function allowing to customize the merge function. The perfect use exemple is to merge nested array :

mergeWith(
 { a: [1, 2] }, 
 { a: [3, 4] }, 
 (a, b) => Array.isArray(a) && Array.isArray(b) => [...a, ...b] : undefined
) 
// => { a: [1, 2, 3, 4] } 

lodash doc: https://lodash.com/docs/4.17.15#mergeWith

JustinMartinDev avatar Aug 02 '23 13:08 JustinMartinDev

Hi, surely a good addition! We could add this to the merge function, similar to difference where you can append a compare function as the last parameter. But I don't know when I will find the time to do this. A PR would be appreciated!

Maggi64 avatar Aug 06 '23 08:08 Maggi64

Hi, any updates?

danilrez avatar Jan 24 '24 06:01 danilrez

I tried for a short while to extend the merge Function, but didn't found a good enough solution that would be fully typesafe. A MR is appreciated, in the next few months I will have the time to look at it again.

Maggi64 avatar Feb 29 '24 10:02 Maggi64