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

format modifies options objects given to it #1516

Closed
jaubourg opened this issue Dec 20, 2018 · 4 comments
Closed

format modifies options objects given to it #1516

jaubourg opened this issue Dec 20, 2018 · 4 comments

Comments

@jaubourg
Copy link
Contributor

const options = {
  "type": "jpeg",
  "quality": 50,
};

sharpInstance.format( options );

options.hasOwnProperty( "trellisQuantisation" ); // true

Bumped into this while doing some unit testing where I was using the object given to format elsewhere in a deepEqual.

It's usually considered good practice not to modify objects passed as arguments. I personally thought I was going mad before realizing sharp.format had this undocumented side effect.

Not sure if this is generalized to the whole code base.

@jaubourg
Copy link
Contributor Author

I had some brain malfunction, it's jpeg(), webp(), png(), etc.

Was thinking about the old API :/

lovell added a commit that referenced this issue Dec 21, 2018
@lovell
Copy link
Owner

lovell commented Dec 21, 2018

Good spot, thanks for reporting this. The options of jpeg with an alternative spelling were affected - commit a54fe9f should deal with the problem.

@lovell lovell added this to the v0.21.2 milestone Dec 21, 2018
@jaubourg
Copy link
Contributor Author

Thanks for this @lovell and merry Christmas 😊

@lovell
Copy link
Owner

lovell commented Jan 13, 2019

v0.21.2 now available.

@lovell lovell closed this as completed Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants