@@ -47,7 +47,10 @@ const {
4747const {
4848 inspect,
4949} = require ( 'internal/util/inspect' ) ;
50- const { promisify } = require ( 'internal/util' ) ;
50+ const {
51+ kEmptyObject,
52+ promisify,
53+ } = require ( 'internal/util' ) ;
5154const { validateAbortSignal } = require ( 'internal/validators' ) ;
5255
5356/**
@@ -128,7 +131,9 @@ const superQuestion = _Interface.prototype.question;
128131 */
129132Interface . prototype . question = function ( query , options , cb ) {
130133 cb = typeof options === 'function' ? options : cb ;
131- options = typeof options === 'object' && options !== null ? options : { } ;
134+ if ( options === null || typeof options !== 'object' ) {
135+ options = kEmptyObject ;
136+ }
132137
133138 if ( options . signal ) {
134139 validateAbortSignal ( options . signal , 'options.signal' ) ;
@@ -154,7 +159,9 @@ Interface.prototype.question = function(query, options, cb) {
154159 }
155160} ;
156161Interface . prototype . question [ promisify . custom ] = function question ( query , options ) {
157- options = typeof options === 'object' && options !== null ? options : { } ;
162+ if ( options === null || typeof options !== 'object' ) {
163+ options = kEmptyObject ;
164+ }
158165
159166 if ( options . signal && options . signal . aborted ) {
160167 return PromiseReject (
@@ -457,7 +464,7 @@ Interface.prototype._moveCursor = _Interface.prototype[kMoveCursor];
457464Interface . prototype . _ttyWrite = _Interface . prototype [ kTtyWrite ] ;
458465
459466function _ttyWriteDumb ( s , key ) {
460- key = key || { } ;
467+ key = key || kEmptyObject ;
461468
462469 if ( key . name === 'escape' ) return ;
463470
0 commit comments