fs: remove unneeded return statement

The `writable._write()` implementation does not need to return anything,
only call the callback.

PR-URL: https://github.com/nodejs/node/pull/48526
Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
This commit is contained in:
Luigi Pinca 2023-06-26 11:01:35 +02:00 committed by GitHub
parent 7202859402
commit d09ff0db70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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) {

View File

@ -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);