@@ -42,12 +42,15 @@ const {
42
42
isStackOverflowError,
43
43
codes : {
44
44
ERR_CONSOLE_WRITABLE_STREAM ,
45
- ERR_INVALID_ARG_TYPE ,
46
45
ERR_INVALID_ARG_VALUE ,
47
46
ERR_INCOMPATIBLE_OPTION_PAIR ,
48
47
} ,
49
48
} = require ( 'internal/errors' ) ;
50
- const { validateInteger } = require ( 'internal/validators' ) ;
49
+ const {
50
+ validateArray,
51
+ validateInteger,
52
+ validateObject,
53
+ } = require ( 'internal/validators' ) ;
51
54
const { previewEntries } = internalBinding ( 'util' ) ;
52
55
const { Buffer : { isBuffer } } = require ( 'buffer' ) ;
53
56
const {
@@ -136,18 +139,15 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) {
136
139
0 , kMaxGroupIndentation ) ;
137
140
}
138
141
139
- if ( typeof inspectOptions === 'object' && inspectOptions !== null ) {
142
+ if ( inspectOptions !== undefined ) {
143
+ validateObject ( inspectOptions , 'options.inspectOptions' ) ;
144
+
140
145
if ( inspectOptions . colors !== undefined &&
141
146
options . colorMode !== undefined ) {
142
147
throw new ERR_INCOMPATIBLE_OPTION_PAIR (
143
148
'options.inspectOptions.color' , 'colorMode' ) ;
144
149
}
145
150
optionsMap . set ( this , inspectOptions ) ;
146
- } else if ( inspectOptions !== undefined ) {
147
- throw new ERR_INVALID_ARG_TYPE (
148
- 'options.inspectOptions' ,
149
- 'object' ,
150
- inspectOptions ) ;
151
151
}
152
152
153
153
// Bind the prototype functions to this Console instance
@@ -483,8 +483,8 @@ const consoleMethods = {
483
483
484
484
// https://console.spec.whatwg.org/#table
485
485
table ( tabularData , properties ) {
486
- if ( properties !== undefined && ! ArrayIsArray ( properties ) )
487
- throw new ERR_INVALID_ARG_TYPE ( ' properties' , 'Array' , properties ) ;
486
+ if ( properties !== undefined )
487
+ validateArray ( properties , 'properties' ) ;
488
488
489
489
if ( tabularData === null || typeof tabularData !== 'object' )
490
490
return this . log ( tabularData ) ;
0 commit comments