From 3d4f608e42788ddb73eb861f255575b6801c01d8 Mon Sep 17 00:00:00 2001 From: rickyes Date: Mon, 13 Jul 2020 23:49:57 +0800 Subject: [PATCH] stream: rename opts to options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/34339 Refs: https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_stream_finished_stream_options_callback Reviewed-By: Robert Nagy Reviewed-By: Matteo Collina Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/internal/streams/end-of-stream.js | 24 ++++++++++++------------ test/parallel/test-stream-finished.js | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) 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(