Make use of `thisArg` instead of #bind

This commit is contained in:
Andrew Stewart 2014-11-30 15:17:57 -08:00
parent 3eb1da8481
commit 9fe92967bb
1 changed files with 7 additions and 7 deletions

View File

@ -63,7 +63,7 @@ var Robot = module.exports = function Robot(opts) {
methods.forEach(function(method) {
this[method] = this[method].bind(this);
}.bind(this));
}, this);
this.name = opts.name || Robot.randomName();
this.connections = {};
@ -199,7 +199,7 @@ Robot.prototype.initConnections = function(opts) {
Logger.warn("Specifying connections as an array is deprecated, and will be removed in 1.0.0.");
opts.connections.forEach(function(conn) {
this.connection(conn.name, conn);
}.bind(this));
}, this);
}
return this.connections;
@ -270,7 +270,7 @@ Robot.prototype.initDevices = function(opts) {
Logger.warn("Specifying devices as an array is deprecated, and will be removed in 1.0.0.");
opts.devices.forEach(function(device) {
this.device(device.name, device);
}.bind(this));
}, this);
}
return this.devices;
@ -350,7 +350,7 @@ Robot.prototype.startConnections = function(callback) {
Logger.debug(str + ".");
return conn.connect.call(conn, cb);
};
}.bind(this));
}, this);
return Async.parallel(starters, callback);
};
@ -376,7 +376,7 @@ Robot.prototype.startDevices = function(callback) {
Logger.debug(str + ".");
return device.start.call(device, cb);
};
}.bind(this));
}, this);
return Async.parallel(starters, callback);
};
@ -394,13 +394,13 @@ Robot.prototype.halt = function(callback) {
var fns = Object.keys(this.devices).map(function(d) {
var device = this.devices[d];
return device.halt.bind(device);
}.bind(this));
}, this);
Async.parallel(fns, function() {
var fns = Object.keys(this.connections).map(function(c) {
var connection = this.connections[c];
return connection.disconnect.bind(connection);
}.bind(this));
}, this);
Async.parallel(fns, callback);
}.bind(this));