readline: error on falsy values for callback
It was intended, according to in-test comments and common behaviour, that callbacks be either `undefined` or a function, but falsy values were being accepted as meaning "no callback". PR-URL: https://github.com/nodejs/node/pull/28109 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
b17a70f639
commit
04633eeeb9
@ -121,7 +121,7 @@ function Interface(input, output, completer, terminal) {
|
|||||||
input = input.input;
|
input = input.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (completer && typeof completer !== 'function') {
|
if (completer !== undefined && typeof completer !== 'function') {
|
||||||
throw new ERR_INVALID_OPT_VALUE('completer', completer);
|
throw new ERR_INVALID_OPT_VALUE('completer', completer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +366,26 @@ function isWarned(emitter) {
|
|||||||
type: TypeError,
|
type: TypeError,
|
||||||
code: 'ERR_INVALID_OPT_VALUE'
|
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
|
// Constructor throws if historySize is not a positive number
|
||||||
|
Loading…
x
Reference in New Issue
Block a user