expressjs / express

Fast, unopinionated, minimalist web framework for node.
https://expressjs.com
MIT License
65.73k stars 16.35k forks source link

Refactor: simplify req.acceptsCharsets with spread syntax #6138

Open Ayoub-Mabrouk opened 2 weeks ago

Ayoub-Mabrouk commented 2 weeks ago

Replaces arguments with spread syntax (...charsets) in req.acceptsCharsets, making the function more concise and improving readability. The new implementation passes arguments directly to accepts(this).charsets, achieving the same functionality with cleaner code.

Abdel-Monaam-Aouini commented 2 weeks ago

already added ! https://github.com/expressjs/express/pull/6088

Ayoub-Mabrouk commented 2 weeks ago

already added ! #6088

Hello @Abdel-Monaam-Aouini Thanks for your input on this! I went with a slightly different approach to keep things concise by calling accept.charsets(...charsets) directly, avoiding the intermediate accept variable. This makes the code a bit more streamlined and skips a minor, unnecessary allocation. I thought this might be more consistent with our style, but I’m happy to discuss if you see other benefits to your approach!