stream: rename opts to options

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 <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
rickyes authored and Anna Henningsen committed 2020-07-16 00:28:13 +02:00
1 parent fbc38ee134
commit 48404a179f
2 files changed
+13 -13

No files matched your search

+12 -12
View File
@@ -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 = (
+1 -1
View File
@@ -145,7 +145,7 @@ const { promisify } = require('util');
() => finished(rs, 'foo', () => {}),
{
code: 'ERR_INVALID_ARG_TYPE',
message: /opts/
message: /options/
}
);
assert.throws(