Skip to content

Commit 0cd9d86

Browse files
Refactor toBuffer function to simplify buffer check logic (#201)
The function now directly returns the existing buffer if the input is already a buffer, eliminating the need for a negated condition. This improves code readability and maintains functionality by ensuring that non-buffer inputs are converted to a buffer using the specified encoding.
1 parent 0a10f23 commit 0cd9d86

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function shouldTransform (req, res) {
277277
*/
278278

279279
function toBuffer (chunk, encoding) {
280-
return !Buffer.isBuffer(chunk)
281-
? Buffer.from(chunk, encoding)
282-
: chunk
280+
return Buffer.isBuffer(chunk)
281+
? chunk
282+
: Buffer.from(chunk, encoding)
283283
}

0 commit comments

Comments
 (0)