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.

PR-URL: #48526
Reviewed-By: Keyhan Vakil <[email protected]>
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Deokjin Kim <[email protected]>
  • Loading branch information
lpinca authored and RafaelGSS committed Jul 3, 2023
1 parent 4efa680 commit 4cad9fd
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, common.mustCall(() => {
calledSynchronously = true;
}, 1));

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

fs.closeSync(fd);
Expand Down

0 comments on commit 4cad9fd

Please sign in to comment.