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

refactor: res.download with lower complexity #6302

Closed
wants to merge 2 commits into from

Conversation

criszst
Copy link

@criszst criszst commented Jan 28, 2025

Description

This PR refactors the res.download function to reduce complexity and improve readability while maintaining existing functionality.

Changes

  • Simplified argument extraction logic using modern JavaScript methods
  • Replaced multiple if-else statements with more concise alternatives
  • Utilized ES6+ features like arrow functions and Object.assign
  • Improved code organization for better maintainability
  • Add examples and params types on DOCS

Motivation and Context

The existing implementation of res.download was functional but complex (with multiple nested conditions). This refactor aims to make the code more straightforward and easier to understand, which should aid in future maintenance and reduce the likelihood of bugs.

How Has This Been Tested?

  • Ran existing test suite to ensure no regression

Additional Notes

This refactor doesn't change the function's API or behavior, so it should be a low-risk change. However, thorough review and testing are appreciated to ensure no edge cases have been overlooked ☺️
By the way, I believe it is possible to refactor further, but I don't want to risk it before this pull-request

@criszst criszst changed the title refactor: res.download lower complexity refactor: res.download with lower complexity Jan 30, 2025
@wesleytodd
Copy link
Member

Hey @criszst, thanks for your first time PR here. Unfortunately we do not accept style change PRs. I would love to see the improved JSDoc as a separate PR we can merge, but the code changes here are purely style preferences.

@wesleytodd wesleytodd closed this Feb 4, 2025
@criszst
Copy link
Author

criszst commented Feb 4, 2025

Hey @criszst, thanks for your first time PR here. Unfortunately we do not accept style change PRs. I would love to see the improved JSDoc as a separate PR we can merge, but the code changes here are purely style preferences.

ok, tyy. Btw i pretend to add some JSDoc in the future.

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