@@ -151,9 +151,11 @@ class Socket extends EventEmitter {
151
151
case "stream" :
152
152
this . _socket = new zmq . Stream ( )
153
153
break
154
+ default :
155
+ throw new Error ( `Invalid socket type: ${ type } ` )
154
156
}
155
157
156
- const recv = async ( ) => {
158
+ const recv = ( ) => {
157
159
this . once ( "_flushRecv" , async ( ) => {
158
160
while ( ! this . _socket . closed && ! this . _paused ) {
159
161
await this . _recv ( )
@@ -257,7 +259,7 @@ class Socket extends EventEmitter {
257
259
. catch ( err => {
258
260
process . nextTick ( ( ) => {
259
261
if ( cb ) {
260
- cb ( err )
262
+ cb ( err as Error )
261
263
} else {
262
264
this . emit ( "error" , err )
263
265
}
@@ -281,7 +283,7 @@ class Socket extends EventEmitter {
281
283
. catch ( err => {
282
284
process . nextTick ( ( ) => {
283
285
if ( cb ) {
284
- cb ( err )
286
+ cb ( err as Error )
285
287
} else {
286
288
this . emit ( "error" , err )
287
289
}
@@ -303,10 +305,10 @@ class Socket extends EventEmitter {
303
305
304
306
send (
305
307
message : zmq . MessageLike [ ] | zmq . MessageLike ,
306
- flags : number | undefined | null = 0 ,
308
+ givenFlags : number | undefined | null = 0 ,
307
309
cb : Callback | undefined = undefined ,
308
310
) {
309
- flags = ( flags ?? 0 ) | 0
311
+ const flags = ( givenFlags ?? 0 ) | 0
310
312
this . _msg = this . _msg . concat ( message )
311
313
if ( ( flags & sendOptions . ZMQ_SNDMORE ) === 0 ) {
312
314
this . _sendQueue . push ( [ this . _msg , cb ] )
@@ -474,8 +476,9 @@ class Socket extends EventEmitter {
474
476
}
475
477
}
476
478
477
- setsockopt ( option : number | keyof typeof shortOptions , value : any ) {
478
- option = typeof option !== "number" ? shortOptions [ option ] : option
479
+ setsockopt ( givenOption : number | keyof typeof shortOptions , value : any ) {
480
+ const option =
481
+ typeof givenOption === "number" ? givenOption : shortOptions [ givenOption ]
479
482
480
483
switch ( option ) {
481
484
case longOptions . ZMQ_AFFINITY :
@@ -613,8 +616,9 @@ class Socket extends EventEmitter {
613
616
return this
614
617
}
615
618
616
- getsockopt ( option : number | keyof typeof shortOptions ) {
617
- option = typeof option !== "number" ? shortOptions [ option ] : option
619
+ getsockopt ( givenOption : number | keyof typeof shortOptions ) {
620
+ const option =
621
+ typeof givenOption !== "number" ? shortOptions [ givenOption ] : givenOption
618
622
619
623
switch ( option ) {
620
624
case longOptions . ZMQ_AFFINITY :
@@ -736,10 +740,9 @@ for (const key in shortOptions) {
736
740
get ( this : Socket ) {
737
741
return this . getsockopt ( shortOptions [ key as keyof typeof shortOptions ] )
738
742
} ,
739
- set ( this : Socket , val : string | Buffer ) {
740
- if ( "string" === typeof val ) {
741
- val = Buffer . from ( val , "utf8" )
742
- }
743
+ set ( this : Socket , givenVal : string | Buffer ) {
744
+ const val =
745
+ typeof givenVal === "string" ? Buffer . from ( givenVal , "utf8" ) : givenVal
743
746
return this . setsockopt (
744
747
shortOptions [ key as keyof typeof shortOptions ] ,
745
748
val ,
0 commit comments