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

Clone options to innerOptions #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manbomb
Copy link

@manbomb manbomb commented Oct 13, 2021

This change prevents the methods from changing the content of the "options" object passed as a parameter.

@brendanashworth
Copy link
Owner

Is this a problem? Not sure how this could cause a bug

@manbomb
Copy link
Author

manbomb commented Oct 14, 2021

This is not a problem, however, it is not good practice to change the parameters passed to a function or method, they should be immutable.

var innerOptions = {...options};

// Set defaults.
innerOptions = innerOptions || {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to just change this line to be options = {...options} || {};? Then you don't need to rename it to innerOptions and most of the diff disappears.

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.

2 participants