mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
fs: only use Buffer.concat in promises.readFile when necessary
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
8cecce3ff4
commit
ad12fefcb0
1 file changed
+1
-1
@@ -331,7 +331,7 @@ async function readFileHandle(filehandle, options) {
|
||||
ArrayPrototypePush(chunks, 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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user