File tree 1 file changed +15
-14
lines changed
1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -283,20 +283,21 @@ const kSetNoDelay = Symbol('kSetNoDelay');
283
283
284
284
function Socket ( options ) {
285
285
if ( ! ( this instanceof Socket ) ) return new Socket ( options ) ;
286
- const invalidKeys = [
287
- 'objectMode' ,
288
- 'readableObjectMode' ,
289
- 'writableObjectMode' ,
290
- ] ;
291
- invalidKeys . forEach ( ( invalidKey ) => {
292
- if ( ObjectKeys ( options ) . includes ( invalidKey ) ) {
293
- throw new ERR_INVALID_ARG_VALUE (
294
- `options.${ invalidKey } ` ,
295
- options [ invalidKey ] ,
296
- 'is not supported'
297
- ) ;
298
- }
299
- } ) ;
286
+ if ( options . objectMode ) {
287
+ throw new ERR_INVALID_ARG_VALUE (
288
+ 'options.objectMode' ,
289
+ options . objectMode ,
290
+ 'is not supported'
291
+ ) ;
292
+ } else if ( options . readableObjectMode || options . writableObjectMode ) {
293
+ throw new ERR_INVALID_ARG_VALUE (
294
+ `options.${
295
+ options . readableObjectMode ? 'readableObjectMode' : 'writableObjectMode'
296
+ } `,
297
+ options . readableObjectMode || options . writableObjectMode ,
298
+ 'is not supported'
299
+ ) ;
300
+ }
300
301
301
302
this . connecting = false ;
302
303
// Problem with this is that users can supply their own handle, that may not
You can’t perform that action at this time.
0 commit comments