Question: Any way to customize merge to "replace" arrays?

Author: is-jonreevesCreated Sep 19, 2024Updated Apr 22, 2026
Labelsp2: new feature

We often need to merge deep options where there is usually a base/initial set of defaults that are then overridden by the input. I think this is a pretty common usecase for property-sheets/configurations.

Historically we've had lodash handy and have leaned on lodash.merge for that, but we started trying to move away from it. Recently we went tested out a whole collection of different util libs including radash, but found the merge functionality in most of them to be different to what "we" expected. We ended up choosing to use deepmerge-ts for this specific function in the end (as it was customizable).

I just stumbled across es-toolkit and played with your merge function, I noted that when merging arrays the strategy seems to be index replacement. Is there anyway to change/customize this? In the usecase described above, typically the expectation would be whole array replacement when present, skip when undefined.

If not, is this something you would consider adding, or is there perhaps another more appropriate function that I might have overlooked?