From 116e6bb4c8474b40fe316f86c86815f8c51701be Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sat, 24 Sep 2016 02:46:55 -0400 Subject: [PATCH] Clean up totalShards default --- src/sharding/ShardingManager.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sharding/ShardingManager.js b/src/sharding/ShardingManager.js index 4be1cf9b9..2f71427d6 100644 --- a/src/sharding/ShardingManager.js +++ b/src/sharding/ShardingManager.js @@ -17,7 +17,7 @@ class ShardingManager extends EventEmitter { * @param {number} [totalShards=1] Number of shards to default to spawning * @param {boolean} [respawn=true] Respawn a shard when it dies */ - constructor(file, totalShards, respawn = true) { + constructor(file, totalShards = 1, respawn = true) { super(); /** @@ -34,12 +34,12 @@ class ShardingManager extends EventEmitter { * Amount of shards that this manager is going to spawn * @type {number} */ - this.totalShards = typeof totalShards !== 'undefined' ? totalShards : 1; - if (typeof this.totalShards !== 'number' || isNaN(this.totalShards)) { + this.totalShards = totalShards; + if (typeof totalShards !== 'number' || isNaN(totalShards)) { throw new TypeError('Amount of shards must be a number.'); } - if (this.totalShards < 1) throw new RangeError('Amount of shards must be at least 1.'); - if (this.totalShards !== Math.floor(this.totalShards)) throw new RangeError('Amount of shards must be an integer.'); + if (totalShards < 1) throw new RangeError('Amount of shards must be at least 1.'); + if (totalShards !== Math.floor(totalShards)) throw new RangeError('Amount of shards must be an integer.'); this.respawn = respawn;