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: saveGif's third argument made more optional #5931

Merged
merged 5 commits into from
Jan 8, 2023
Merged

fix: saveGif's third argument made more optional #5931

merged 5 commits into from
Jan 8, 2023

Conversation

Neilblaze
Copy link
Contributor

saveGif currently accepts an optional third argument in the form of an object with delay and unit keys. If an object is passed with only one of those keys defined, then it returns an error message respectively.

Resolves #5927

Changes:

  • Made optional third argument of saveGif even more optional.
  • Checks are now performed on delay and units rather than options.delay and options.units

PR Checklist

Thanks for the assist @davepagurek 🙌

@welcome
Copy link

welcome bot commented Jan 4, 2023

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

@Qianqianye Qianqianye requested a review from davepagurek January 4, 2023 19:55
Copy link
Contributor Author

@Neilblaze Neilblaze left a comment

Choose a reason for hiding this comment

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

My bad 😓
I think it'll be this ⬇️ (You've mistakenly added semicolons after comments) 😅

const delay = (options && options.delay) || 0;  // in seconds
const units = (options && options.units) || 'seconds';  // either 'seconds' or 'frames'

Thanks for the catch @Qianqianye 💙

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this task! Just one comment about keeping our input checking around.

@@ -238,18 +238,10 @@ p5.prototype.saveGif = async function(
if (typeof duration !== 'number') {
throw TypeError('Duration parameter must be a number');
}
// if arguments in the options object are not correct, cancel operation
if (typeof options.delay !== 'number') {
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you feel about putting these two checks back in, but checking delay and units rather than options.delay and options.units? That way, if one accidentally specifies units as, for example, 's' instead of 'seconds', they'll still hit an error. It will mean moving it to after we define those variables, I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that should be good! I'm on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

// if arguments in the options object are not correct, cancel operation
if (typeof options.delay !== 'number') {
if (typeof delay !== 'number' && delay !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good! Just for my understanding, was there a case that wasn't being handled that the && delay !== null is needed for?

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Thanks for making this change!

@Qianqianye Qianqianye closed this Jan 8, 2023
@Qianqianye Qianqianye reopened this Jan 8, 2023
@Qianqianye
Copy link
Contributor

Thank you both @Neilblaze and @davepagurek. I restarted the check process, and it's all passed. Ready to merge this PR if it looks good to you both.

@davepagurek
Copy link
Contributor

Thanks @Qianqianye!

@davepagurek davepagurek merged commit ed3add5 into processing:main Jan 8, 2023
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.

make saveGif's third argument even more optional
4 participants