@@ -15,9 +15,9 @@ class ChannelModel extends EventEmitter {
15
15
constructor ( connection ) {
16
16
super ( ) ;
17
17
this . connection = connection ;
18
- const self = this ;
18
+
19
19
[ 'error' , 'close' , 'blocked' , 'unblocked' ] . forEach ( ev => {
20
- connection . on ( ev , self . emit . bind ( self , ev ) ) ;
20
+ connection . on ( ev , this . emit . bind ( this , ev ) ) ;
21
21
} ) ;
22
22
}
23
23
@@ -56,9 +56,8 @@ class Channel extends BaseChannel {
56
56
// response's fields; this is intended to be suitable for implementing
57
57
// API procedures.
58
58
rpc ( method , fields , expect ) {
59
- const self = this ;
60
59
return Promise . fromCallback ( cb => {
61
- return self . _rpc ( method , fields , expect , cb ) ;
60
+ return this . _rpc ( method , fields , expect , cb ) ;
62
61
} )
63
62
. then ( f => {
64
63
return f . fields ;
@@ -75,9 +74,8 @@ class Channel extends BaseChannel {
75
74
}
76
75
77
76
close ( ) {
78
- const self = this ;
79
77
return Promise . fromCallback ( cb => {
80
- return self . closeBecause ( "Goodbye" , defs . constants . REPLY_SUCCESS ,
78
+ return this . closeBecause ( "Goodbye" , defs . constants . REPLY_SUCCESS ,
81
79
cb ) ;
82
80
} ) ;
83
81
}
@@ -165,37 +163,34 @@ class Channel extends BaseChannel {
165
163
}
166
164
167
165
consume ( queue , callback , options ) {
168
- const self = this ;
169
166
// NB we want the callback to be run synchronously, so that we've
170
167
// registered the consumerTag before any messages can arrive.
171
168
const fields = Args . consume ( queue , options ) ;
172
169
return Promise . fromCallback ( cb => {
173
- self . _rpc ( defs . BasicConsume , fields , defs . BasicConsumeOk , cb ) ;
170
+ this . _rpc ( defs . BasicConsume , fields , defs . BasicConsumeOk , cb ) ;
174
171
} )
175
172
. then ( ok => {
176
- self . registerConsumer ( ok . fields . consumerTag , callback ) ;
173
+ this . registerConsumer ( ok . fields . consumerTag , callback ) ;
177
174
return ok . fields ;
178
175
} ) ;
179
176
}
180
177
181
178
cancel ( consumerTag ) {
182
- const self = this ;
183
179
return Promise . fromCallback ( cb => {
184
- self . _rpc ( defs . BasicCancel , Args . cancel ( consumerTag ) ,
180
+ this . _rpc ( defs . BasicCancel , Args . cancel ( consumerTag ) ,
185
181
defs . BasicCancelOk ,
186
182
cb ) ;
187
183
} )
188
184
. then ( ok => {
189
- self . unregisterConsumer ( consumerTag ) ;
185
+ this . unregisterConsumer ( consumerTag ) ;
190
186
return ok . fields ;
191
187
} ) ;
192
188
}
193
189
194
190
get ( queue , options ) {
195
- const self = this ;
196
191
const fields = Args . get ( queue , options ) ;
197
192
return Promise . fromCallback ( cb => {
198
- return self . sendOrEnqueue ( defs . BasicGet , fields , cb ) ;
193
+ return this . sendOrEnqueue ( defs . BasicGet , fields , cb ) ;
199
194
} )
200
195
. then ( f => {
201
196
if ( f . id === defs . BasicGetEmpty ) {
@@ -204,7 +199,7 @@ class Channel extends BaseChannel {
204
199
else if ( f . id === defs . BasicGetOk ) {
205
200
const fields = f . fields ;
206
201
return new Promise ( resolve => {
207
- self . handleMessage = acceptMessage ( m => {
202
+ this . handleMessage = acceptMessage ( m => {
208
203
m . fields = fields ;
209
204
resolve ( m ) ;
210
205
} ) ;
0 commit comments