Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: Rename opts to options #34339

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/internal/streams/end-of-stream.js
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
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