Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Dec 7, 2023
1 parent 6c0f5ca commit bc562af
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/api/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,9 @@ function consumeStart (consume) {
* @param {Buffer} buffer
*/
function utf8DecodeBytes (buffer) {
if (buffer.length === 0) {
return ''
}
// 1.
// 2.
// 3.
// 4.
return buffer.toString('utf8', buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF ? 3 : 0)
return buffer.length >= 3
? buffer.toString('utf8', buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF ? 3 : 0)
: buffer.toString('utf8')
}

function consumeEnd (consume) {
Expand Down

0 comments on commit bc562af

Please sign in to comment.