Skip to content

Commit d79d142

Browse files
ronagtargos
authored andcommitted
fs: use fs.writev() internally
Avoid using internal API in fs implementation. PR-URL: #29189 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent c4f6077 commit d79d142

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

lib/internal/fs/streams.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
const { Math, Object } = primordials;
44

5-
const {
6-
FSReqCallback,
7-
writeBuffers
8-
} = internalBinding('fs');
95
const {
106
ERR_INVALID_ARG_TYPE,
117
ERR_OUT_OF_RANGE
@@ -325,18 +321,6 @@ WriteStream.prototype._write = function(data, encoding, cb) {
325321
};
326322

327323

328-
function writev(fd, chunks, position, callback) {
329-
function wrapper(err, written) {
330-
// Retain a reference to chunks so that they can't be GC'ed too soon.
331-
callback(err, written || 0, chunks);
332-
}
333-
334-
const req = new FSReqCallback();
335-
req.oncomplete = wrapper;
336-
writeBuffers(fd, chunks, position, req);
337-
}
338-
339-
340324
WriteStream.prototype._writev = function(data, cb) {
341325
if (typeof this.fd !== 'number') {
342326
return this.once('open', function() {
@@ -356,7 +340,7 @@ WriteStream.prototype._writev = function(data, cb) {
356340
size += chunk.length;
357341
}
358342

359-
writev(this.fd, chunks, this.pos, function(er, bytes) {
343+
fs.writev(this.fd, chunks, this.pos, function(er, bytes) {
360344
if (er) {
361345
self.destroy();
362346
return cb(er);

0 commit comments

Comments
 (0)