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

Open
wants to merge 2 commits into
base: master
Choose a base branch
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
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.

1 participant