8000 ✨ Bring back nullish values support via option · Issue #95 · unjs/defu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
✨ Bring back nullish values support via option #95
Open
@jd-solanki

Description

@jd-solanki

Describe the feature

Hi πŸ‘‹πŸ»

I'm author of Anu UI lib. I'm using defu and it's doing an amazing job until I found that it skips nullish values undefined & null 😞

Why?

If we want to allow explicitly set null or undefined for property it's not possible ATM.

I'm trying to implement global prop defaults via vue plugin options for my lib. If user wants to disable some prop, the user can pass undefined in the plugin option but unfortunately defu skips that and uses default from component props definition 😬

Proposed Solution

We can keep the defu's default behavior and introduce option to consider nullish value while merging like below:

defu(obj, defaults, { skipNullish: false })

Additional context

I guess this was already implemented before and we removed this in this PR.

I can use mentioned alternatives but those aren't from unjs family and are outdated (might be vulnerable) which makes defu one and only choice.

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0