Skip to content

Commit

Permalink
fs: remove unneeded return statement
Browse files Browse the repository at this point in the history
The `writable._write()` implementation does not need to return anything, only
call the callback.
  • Loading branch information
lpinca committed Jun 22, 2023
1 parent b352e0c commit 4e3ba1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/internal/fs/sync_write_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ObjectSetPrototypeOf(SyncWriteStream, Writable);
SyncWriteStream.prototype._write = function(chunk, encoding, cb) {
writeSync(this.fd, chunk, 0, chunk.length);
cb();
return true;
};

SyncWriteStream.prototype._destroy = function(err, cb) {
Expand Down
7 changes: 6 additions & 1 deletion test/parallel/test-internal-fs-syncwritestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const filename = path.join(tmpdir.path, 'sync-write-stream.txt');
const stream = new SyncWriteStream(fd);
const chunk = Buffer.from('foo');

assert.strictEqual(stream._write(chunk, null, common.mustCall(1)), true);
let calledSynchronously = false;
stream._write(chunk, null, () => {
calledSynchronously = true;
});

assert.ok(calledSynchronously);
assert.strictEqual(fs.readFileSync(filename).equals(chunk), true);

fs.closeSync(fd);
Expand Down

0 comments on commit 4e3ba1c

Please sign in to comment.