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

readline: error on falsy values for callback #28109

Closed
wants to merge 1 commit into from
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function Interface(input, output, completer, terminal) {
input = input.input;
}

if (completer && typeof completer !== 'function') {
if (completer !== undefined && typeof completer !== 'function') {
throw new ERR_INVALID_OPT_VALUE('completer', completer);
}

Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,26 @@ function isWarned(emitter) {
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE'
});

common.expectsError(function() {
readline.createInterface({
input: fi,
completer: ''
});
}, {
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE'
});

common.expectsError(function() {
readline.createInterface({
input: fi,
completer: false
});
}, {
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE'
});
}

// Constructor throws if historySize is not a positive number
Expand Down