Skip to content

Commit

Permalink
Refactor createETagGenerator for improved readability and modern syntax
Browse files Browse the repository at this point in the history
- Replaced function declaration with arrow function
- Separated ternary condition into multiple lines for clarity
- Changed `var` to `const` for better scoping and modern standards
  • Loading branch information
Ayoub-Mabrouk committed Oct 29, 2024
1 parent b31910c commit 62aa2fb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ exports.setCharset = function setCharset(type, charset) {
* @private
*/

function createETagGenerator (options) {
return function generateETag (body, encoding) {
var buf = !Buffer.isBuffer(body)
? Buffer.from(body, encoding)
: body

return etag(buf, options)
}
function createETagGenerator(options) {
return (body, encoding) => {
const buf = Buffer.isBuffer(body)
? body
: Buffer.from(body, encoding);

return etag(buf, options);
};
}

/**
Expand Down

0 comments on commit 62aa2fb

Please sign in to comment.