Skip to content

Commit

Permalink
stream: rename opts to options
Browse files Browse the repository at this point in the history
PR-URL: #34339
Refs: https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_stream_finished_stream_options_callback
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
rickyes authored and MylesBorins committed Jul 27, 2020
1 parent c28453a commit 3d4f608
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ 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);
}

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;
Expand Down Expand Up @@ -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 = (
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const { promisify } = require('util');
() => finished(rs, 'foo', () => {}),
{
code: 'ERR_INVALID_ARG_TYPE',
message: /opts/
message: /options/
}
);
assert.throws(
Expand Down

0 comments on commit 3d4f608

Please sign in to comment.