diff --git a/lib/internal/streams/end-of-stream.js b/lib/internal/streams/end-of-stream.js index bc2d0ccfcaf142..29c0171a4f2b1f 100644 --- a/lib/internal/streams/end-of-stream.js +++ b/lib/internal/streams/end-of-stream.js @@ -41,14 +41,14 @@ function isReadableEnded(stream) { return rState.endEmitted || (rState.ended && rState.length === 0); } -function eos(stream, opts, callback) { +function eos(stream, options, callback) { if (arguments.length === 2) { - callback = opts; - opts = {}; - } else if (opts == null) { - opts = {}; - } else if (typeof opts !== 'object') { - throw new ERR_INVALID_ARG_TYPE('opts', 'object', opts); + callback = options; + options = {}; + } else if (options == null) { + options = {}; + } else if (typeof options !== 'object') { + throw new ERR_INVALID_ARG_TYPE('options', 'object', options); } if (typeof callback !== 'function') { throw new ERR_INVALID_ARG_TYPE('callback', 'function', callback); @@ -56,10 +56,10 @@ function eos(stream, opts, callback) { callback = once(callback); - const readable = opts.readable || - (opts.readable !== false && isReadable(stream)); - const writable = opts.writable || - (opts.writable !== false && isWritable(stream)); + const readable = options.readable || + (options.readable !== false && isReadable(stream)); + const writable = options.writable || + (options.writable !== false && isWritable(stream)); const wState = stream._writableState; const rState = stream._readableState; @@ -144,7 +144,7 @@ function eos(stream, opts, callback) { stream.on('end', onend); stream.on('finish', onfinish); - if (opts.error !== false) stream.on('error', onerror); + if (options.error !== false) stream.on('error', onerror); stream.on('close', onclose); const closed = ( diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js index 4622d2c695e1fa..758f9540479534 100644 --- a/test/parallel/test-stream-finished.js +++ b/test/parallel/test-stream-finished.js @@ -145,7 +145,7 @@ const { promisify } = require('util'); () => finished(rs, 'foo', () => {}), { code: 'ERR_INVALID_ARG_TYPE', - message: /opts/ + message: /options/ } ); assert.throws(