Skip to content

Commit 8a34b30

Browse files
committed
There's no point in supplying a default for the callback
Promises ignore null or undefined continuations anyway.
1 parent 771e109 commit 8a34b30

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

lib/sockets.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ var Duplex = Stream.Duplex || require('readable-stream/duplex');
1010

1111
var delay = global.setImmediate || process.nextTick;
1212

13-
// A default value to substitute when we don't get a callback
14-
function ignore() {}
15-
1613
// Do the tedious string-or-buffer conversion. If I was using byte
1714
// streams, this would be done automatically; however I'm using
1815
// streams in object mode.
@@ -33,6 +30,9 @@ function errorLater(obj) {
3330
}
3431
}
3532

33+
function ignore() {} // for stubbing out methods I don't care about;
34+
// i.e., _read
35+
3636
function Context(url) {
3737
EventEmitter.call(this);
3838
var self = this;
@@ -75,7 +75,7 @@ Context.prototype.socket = function(type, options) {
7575

7676
Context.prototype.close = function(callback) {
7777
this._connection.then(function(c) {
78-
c.close().then(callback || ignore);
78+
c.close().then(callback);
7979
});
8080
};
8181

@@ -181,7 +181,7 @@ PubSocket.prototype.connect = function(destination, callback) {
181181
{durable: false, autoDelete: false})
182182
.then(function(ok) {
183183
self.pubs.push(destination);
184-
}).then(callback || ignore);
184+
}).then(callback);
185185
};
186186

187187
PubSocket.prototype.publish = function(topic, chunk, encoding) {
@@ -241,7 +241,7 @@ SubSocket.prototype.connect = function(source, topic, callback) {
241241
.then(function(ok) {
242242
return ch.bindQueue(queue, source, topic);
243243
})
244-
.then(callback || ignore);
244+
.then(callback);
245245
};
246246

247247
// AMQP and the stream API don't really work well together here. I'm
@@ -267,7 +267,7 @@ PushSocket.prototype.connect = function(destination, callback) {
267267
ch.assertQueue(destination, {durable: this.options.persistent})
268268
.then(function(ok) {
269269
self.queues.push(destination);
270-
}).then(callback || ignore);
270+
}).then(callback);
271271
};
272272

273273
PushSocket.prototype.write = function(chunk, encoding) {
@@ -306,7 +306,7 @@ PullSocket.prototype.connect = function(source, callback) {
306306
}, {noAck:false}).then(function(ok) {
307307
self.consumers[source] = ok.consumerTag;
308308
});
309-
}).then(callback || ignore);
309+
}).then(callback);
310310
};
311311

312312
PullSocket.prototype._read = ignore;
@@ -335,7 +335,7 @@ WorkerSocket.prototype.connect = function(source, callback) {
335335
}, {noAck:false}).then(function(ok) {
336336
self.consumers[source] = ok.consumerTag;
337337
});
338-
}).then(callback || ignore);
338+
}).then(callback);
339339
};
340340

341341
WorkerSocket.prototype.ack = function() {
@@ -397,7 +397,7 @@ ReqSocket.prototype.connect = function(destination, callback) {
397397
ch.assertQueue(destination, {durable: this.options.persistent})
398398
.then(function(ok) {
399399
self.queues.push(ok.queue);
400-
}).then(callback || ignore);
400+
}).then(callback);
401401
};
402402

403403
ReqSocket.prototype.write = function(chunk, encoding) {
@@ -448,7 +448,7 @@ RepSocket.prototype.connect = function(source, callback) {
448448
}, {noAck:false}).then(function(ok) {
449449
self.consumers[source] = ok.consumerTag;
450450
});
451-
}).then(callback || ignore);
451+
}).then(callback);
452452
};
453453

454454
RepSocket.prototype.write = function(chunk, encoding) {
@@ -493,7 +493,7 @@ TaskSocket.prototype.connect = function(destination, callback) {
493493
{durable: this.options.persistent})
494494
.then(function(ok) {
495495
queues.push(destination);
496-
}).then(callback || ignore);
496+
}).then(callback);
497497
};
498498

499499
TaskSocket.prototype.write = function(chunk, encoding) {

0 commit comments

Comments
 (0)