X Tutup
The Wayback Machine - https://web.archive.org/web/20230218233743/https://github.com/nodejs/node/commit/e582832643
Skip to content
Permalink
Browse files
fs: only use Buffer.concat in promises.readFile when necessary
PR-URL: #37127
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and targos committed May 1, 2021
1 parent 6264ac1 commit e582832
Showing 1 changed file with 1 addition and 1 deletion.
@@ -311,7 +311,7 @@ async function readFileHandle(filehandle, options) {
chunks.push(buffer.slice(0, bytesRead));
} while (!endOfFile);

const result = Buffer.concat(chunks);
const result = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);

return options.encoding ? result.toString(options.encoding) : result;
}

0 comments on commit e582832

Please sign in to comment.
X Tutup