Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assign does not handle null values well #373

Open
anion155 opened this issue Dec 22, 2023 · 1 comment
Open

assign does not handle null values well #373

anion155 opened this issue Dec 22, 2023 · 1 comment

Comments

@anion155
Copy link

anion155 commented Dec 22, 2023

const r = require('radash')
const result = r.assign({ a: {g:5} }, { a: null })
console.log(result)

Expected result would be { a: null }, but it is { a: {g:5} }

@MoozonWei
Copy link

MoozonWei commented May 10, 2024

I think this issue is caused by this line:

if (!initial || !override) return initial ?? override ?? {}

Although this assign function is designed to merge two objects, you will still encounter situations where you need to merge non-objects and objects when it make recursive calls.

Maybe we can modify this function to be able to merge objects and non-objects, then the problem will be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants