fs: remove broken code in promises/write
That code expects the last argument to be a callback. When it's not a callback, it shifts arguments, defaulting encoding to 'utf-8', which is clearly broken. Old signature: (fd, string[, position[, encoding]], callback) New signature: (fd, string[, position[, encoding]]) PR-URL: https://github.com/nodejs/node/pull/20407 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jamie Davis <davisjam@vt.edu> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
dd03709148
commit
ca6b12e28d
@ -244,15 +244,6 @@ async function write(handle, buffer, offset, length, position) {
|
||||
|
||||
if (typeof buffer !== 'string')
|
||||
buffer += '';
|
||||
if (typeof position !== 'function') {
|
||||
if (typeof offset === 'function') {
|
||||
position = offset;
|
||||
offset = null;
|
||||
} else {
|
||||
position = length;
|
||||
}
|
||||
length = 'utf8';
|
||||
}
|
||||
const bytesWritten = (await binding.writeString(handle.fd, buffer, offset,
|
||||
length, kUsePromises)) || 0;
|
||||
return { bytesWritten, buffer };
|
||||
|
Loading…
x
Reference in New Issue
Block a user