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

Fix nested objects being modified #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cloudrac3r
Copy link

In 2.0.1, nested objects in parameters could be mutated in some circumstances depending on the shape of the other object parameters. I found this extremely unpredictable, and I was sure it was a bug until I looked closely through the source code and found this behaviour was actually specified in the tests.

With my change, the original parameters should now never be mutated. (Apart from the first parameter, which is always mutated, no changes there.)

I think you should merge my pull request because the expected behaviour of the library is that the second parameter and onwards will not be modified at all. The npm description says "Deeply mix the properties of objects into the first object", implying the other objects won't be changed. My pull request makes the library safer and more predictable.

However, since the behaviour is different now, I've increased the version to 3.0.0 so nobody's code would be broken by automated updates if they were relying on the old behaviour.

Fixes #14.

See the tests to see exactly how the behaviour has changed.

@cloudrac3r cloudrac3r force-pushed the fix-nested-objects-being-modified branch from f644738 to 2dd70d6 Compare August 23, 2023 03:30
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

Successfully merging this pull request may close these issues.

The second object was changed when the first is "{}"
1 participant