radash
radash copied to clipboard
`assign` does not handle `null` values well
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} }
I think this issue is caused by this line: https://github.com/sodiray/radash/blob/069b26cdd7d62e6ac16a0ad3baa1c9abcca420bc/src/object.ts#L276
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.
Hi @anion155 and @MoozonWei, I have this fixed over at the Radashi fork: https://github.com/radashi-org/radashi/pull/112
You can use it today by installing radashi@beta (see changelog here). An official release is pending. If you have any more ideas or feedback, consider sharing it here.