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 <kvakil@sylph.kvakil.me>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
  • Loading branch information
lpinca authored and ruyadorno committed Sep 12, 2023
1 parent 3ae96ae commit c3a27d1
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
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
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 c3a27d1

Please sign in to comment.