Skip to content

Commit 52fc84d

Browse files
committedOct 18, 2021
rm some self variable
1 parent 44e62fd commit 52fc84d

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed
 

‎lib/channel_model.js

+10-15
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class ChannelModel extends EventEmitter {
1515
constructor(connection) {
1616
super();
1717
this.connection = connection;
18-
const self = this;
18+
1919
['error', 'close', 'blocked', 'unblocked'].forEach(ev => {
20-
connection.on(ev, self.emit.bind(self, ev));
20+
connection.on(ev, this.emit.bind(this, ev));
2121
});
2222
}
2323

@@ -56,9 +56,8 @@ class Channel extends BaseChannel {
5656
// response's fields; this is intended to be suitable for implementing
5757
// API procedures.
5858
rpc(method, fields, expect) {
59-
const self = this;
6059
return Promise.fromCallback(cb => {
61-
return self._rpc(method, fields, expect, cb);
60+
return this._rpc(method, fields, expect, cb);
6261
})
6362
.then(f => {
6463
return f.fields;
@@ -75,9 +74,8 @@ class Channel extends BaseChannel {
7574
}
7675

7776
close() {
78-
const self = this;
7977
return Promise.fromCallback(cb => {
80-
return self.closeBecause("Goodbye", defs.constants.REPLY_SUCCESS,
78+
return this.closeBecause("Goodbye", defs.constants.REPLY_SUCCESS,
8179
cb);
8280
});
8381
}
@@ -165,37 +163,34 @@ class Channel extends BaseChannel {
165163
}
166164

167165
consume(queue, callback, options) {
168-
const self = this;
169166
// NB we want the callback to be run synchronously, so that we've
170167
// registered the consumerTag before any messages can arrive.
171168
const fields = Args.consume(queue, options);
172169
return Promise.fromCallback(cb => {
173-
self._rpc(defs.BasicConsume, fields, defs.BasicConsumeOk, cb);
170+
this._rpc(defs.BasicConsume, fields, defs.BasicConsumeOk, cb);
174171
})
175172
.then(ok => {
176-
self.registerConsumer(ok.fields.consumerTag, callback);
173+
this.registerConsumer(ok.fields.consumerTag, callback);
177174
return ok.fields;
178175
});
179176
}
180177

181178
cancel(consumerTag) {
182-
const self = this;
183179
return Promise.fromCallback(cb => {
184-
self._rpc(defs.BasicCancel, Args.cancel(consumerTag),
180+
this._rpc(defs.BasicCancel, Args.cancel(consumerTag),
185181
defs.BasicCancelOk,
186182
cb);
187183
})
188184
.then(ok => {
189-
self.unregisterConsumer(consumerTag);
185+
this.unregisterConsumer(consumerTag);
190186
return ok.fields;
191187
});
192188
}
193189

194190
get(queue, options) {
195-
const self = this;
196191
const fields = Args.get(queue, options);
197192
return Promise.fromCallback(cb => {
198-
return self.sendOrEnqueue(defs.BasicGet, fields, cb);
193+
return this.sendOrEnqueue(defs.BasicGet, fields, cb);
199194
})
200195
.then(f => {
201196
if (f.id === defs.BasicGetEmpty) {
@@ -204,7 +199,7 @@ class Channel extends BaseChannel {
204199
else if (f.id === defs.BasicGetOk) {
205200
const fields = f.fields;
206201
return new Promise(resolve => {
207-
self.handleMessage = acceptMessage(m => {
202+
this.handleMessage = acceptMessage(m => {
208203
m.fields = fields;
209204
resolve(m);
210205
});

0 commit comments

Comments
 (0)
Please sign in to comment.