mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
readline: check for null input in question()
question() checks for objects passed as the recently added options argument. This commit improves that logic to also check for null. PR-URL: https://github.com/nodejs/node/pull/37089 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
1 parent
fe9f4fdba5
commit
3d64d2b5ef
1 file changed
+2
-2
+2
-2
@@ -364,7 +364,7 @@ Interface.prototype.prompt = function(preserveCursor) {
|
||||
|
||||
Interface.prototype.question = function(query, options, cb) {
|
||||
cb = typeof options === 'function' ? options : cb;
|
||||
options = typeof options === 'object' ? options : {};
|
||||
options = typeof options === 'object' && options !== null ? options : {};
|
||||
|
||||
if (options.signal) {
|
||||
options.signal.addEventListener('abort', () => {
|
||||
@@ -385,7 +385,7 @@ Interface.prototype.question = function(query, options, cb) {
|
||||
};
|
||||
|
||||
Interface.prototype.question[promisify.custom] = function(query, options) {
|
||||
options = typeof options === 'object' ? options : {};
|
||||
options = typeof options === 'object' && options !== null ? options : {};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.question(query, options, resolve);
|
||||
|
||||
Reference in new issue
Block a user