Simplify halt code in Robot slightly

This commit is contained in:
Andrew Stewart 2014-11-30 11:47:33 -08:00
parent 0077fe4a8f
commit 3eb1da8481
1 changed files with 2 additions and 8 deletions

View File

@ -393,19 +393,13 @@ Robot.prototype.halt = function(callback) {
var fns = Object.keys(this.devices).map(function(d) { var fns = Object.keys(this.devices).map(function(d) {
var device = this.devices[d]; var device = this.devices[d];
return device.halt.bind(device);
return function(callback) {
device.halt.call(device, callback);
};
}.bind(this)); }.bind(this));
Async.parallel(fns, function() { Async.parallel(fns, function() {
var fns = Object.keys(this.connections).map(function(c) { var fns = Object.keys(this.connections).map(function(c) {
var connection = this.connections[c]; var connection = this.connections[c];
return connection.disconnect.bind(connection);
return function(callback) {
connection.disconnect.call(connection, callback);
};
}.bind(this)); }.bind(this));
Async.parallel(fns, callback); Async.parallel(fns, callback);