express icon indicating copy to clipboard operation
express copied to clipboard

Refactor: simplify req.acceptsCharsets with spread syntax

Open Ayoub-Mabrouk opened this issue 1 year ago • 2 comments

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.

Ayoub-Mabrouk avatar Nov 04 '24 01:11 Ayoub-Mabrouk

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

Abdel-Monaam-Aouini avatar Nov 04 '24 19:11 Abdel-Monaam-Aouini

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!

Ayoub-Mabrouk avatar Nov 05 '24 21:11 Ayoub-Mabrouk