You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Package's name
object-fill-missing-keys
object-merge-advanced
Describe the bug
When comparing two objects using the "object-fill-missing-keys" library with different Boolean values, the values are replaced despite the fact that the value is not missing (is true or false).
If one object is false and the other object is true, true is always returned.
To Reproduce
Steps to reproduce the behavior:
Create one object with false value and one object with true value
Fill object with fillMissing(objectOne, objectTwo)
See output
Object with true value is returned from method
Expected behavior
If the value is true or false (not missing in the object), the original value of the object should always be returned, regardless of the boolean value in the schema (the object according to which the first object fills in the missing values).
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
An error occurs in the "object-merge-advanced" library when comparing Boolean values on this line.
If I use the following code, the Boolean values are returned correctly according to the first (original) object.
Sorry for delay, at first I thought I'll have to recode the object-fill-missing-keys from scratch but with fresh head this morning I've been able to sort this.
I've been using this package to merge JSON data sources for email templates and they follow the data hierarchy (seen in https://codsen.com/os/object-merge-advanced#purpose). I'd prepare schema, and its placeholders would always be boolean false — that's lower in the "food chain" than anything on the source. Technically, this was not a bug for me, but it was for everybody, and this program didn't actually deliver what it promised — besides filling the values it was overwriting source with schema's value if the source was lower in the "values food chain" — like you rightly discovered with { foo: false } vs. schema { foo: true } merges.
The fix was a three-liner, I used object-merge-advanced callback to conditionally merge — if types of schema and original are matching, original is kept. Otherwise, we leave it up to object-merge-advanced to decide (<v.10, original behaviour).
Package's name
object-fill-missing-keys
object-merge-advanced
Describe the bug
When comparing two objects using the "object-fill-missing-keys" library with different Boolean values, the values are replaced despite the fact that the value is not missing (is true or false).
If one object is false and the other object is true, true is always returned.
To Reproduce
Steps to reproduce the behavior:
false
value and one object withtrue
valuefillMissing(objectOne, objectTwo)
true
value is returned from methodExpected behavior
If the value is true or false (not missing in the object), the original value of the object should always be returned, regardless of the boolean value in the schema (the object according to which the first object fills in the missing values).
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
An error occurs in the "object-merge-advanced" library when comparing Boolean values on this line.
If I use the following code, the Boolean values are returned correctly according to the first (original) object.
The text was updated successfully, but these errors were encountered: