From 54140c0819ece3740beafb3217e1bbf2c23ce9ec Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 17 Aug 2019 23:36:59 +0200 Subject: [PATCH] fs: use fs.writev Avoid using internal API in fs implementation. --- lib/internal/fs/streams.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index dfff08dbbd1d2a..87d58a8be55f80 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -2,10 +2,6 @@ const { Math, Object } = primordials; -const { - FSReqCallback, - writeBuffers -} = internalBinding('fs'); const { ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE @@ -325,18 +321,6 @@ WriteStream.prototype._write = function(data, encoding, cb) { }; -function writev(fd, chunks, position, callback) { - function wrapper(err, written) { - // Retain a reference to chunks so that they can't be GC'ed too soon. - callback(err, written || 0, chunks); - } - - const req = new FSReqCallback(); - req.oncomplete = wrapper; - writeBuffers(fd, chunks, position, req); -} - - WriteStream.prototype._writev = function(data, cb) { if (typeof this.fd !== 'number') { return this.once('open', function() { @@ -356,7 +340,7 @@ WriteStream.prototype._writev = function(data, cb) { size += chunk.length; } - writev(this.fd, chunks, this.pos, function(er, bytes) { + fs.writev(this.fd, chunks, this.pos, function(er, bytes) { if (er) { self.destroy(); return cb(er);