chore: use generator for range utility (#8825)

* chore: use generator for range utility

* chore: update doc examples

* chore: fix spelling

* chore: fix typo

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Suneet Tipirneni
2022-12-25 13:43:58 -07:00
committed by GitHub
parent a6941d536c
commit 3160ab0fc7
3 changed files with 60 additions and 14 deletions

View File

@@ -264,11 +264,12 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> {
if (Array.isArray(this.options.shardIds)) {
shardIds = this.options.shardIds;
} else {
shardIds = range(this.options.shardIds.start, this.options.shardIds.end);
const { start, end } = this.options.shardIds;
shardIds = [...range({ start, end: end + 1 })];
}
} else {
const data = await this.fetchGatewayInformation();
shardIds = range(0, (this.options.shardCount ?? data.shards) - 1);
shardIds = [...range(this.options.shardCount ?? data.shards)];
}
this.shardIds = shardIds;