From 9fe92967bb1d151b899904eab47b3d2d74a4899e Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sun, 30 Nov 2014 15:17:57 -0800 Subject: [PATCH] Make use of `thisArg` instead of #bind --- lib/robot.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/robot.js b/lib/robot.js index 28ebed4..c99c347 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -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));