Skip to content

Commit

Permalink
fs: remove broken code in promises/write
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
ChALkeR authored and MylesBorins committed May 9, 2018
1 parent bd27a59 commit eb724f0
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,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 };
Expand Down

0 comments on commit eb724f0

Please sign in to comment.