merge-anything icon indicating copy to clipboard operation
merge-anything copied to clipboard

Handling "undefined"

Open snicol21 opened this issue 7 months ago • 3 comments

Maybe this is by design, but I was surprised to learn that this:

import { merge } from "merge-anything"

const defaultTheme = {}
const theme = undefined

merge(defaultTheme, theme)

Returns undefined. Is this expected, maybe it is, but I was kind of expecting it to return {}. Am I right?

I would hate to have to handle this scenario like this everytime:

merge(defaultTheme, theme || {})

snicol21 avatar Nov 12 '23 15:11 snicol21