UNPKG

@pandorajs/hub

Version:

pandora.js messenge hub

27 lines 678 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Balancer = void 0; /** * Balancer */ class Balancer { constructor(clients) { this.clients = clients; } /** * Pick a random client * @return {SelectedInfo} */ pick() { if (this.clients.length === 1) { return this.clients[0]; } const randomInt = Balancer.getRandomInt(0, this.clients.length - 1); return this.clients[randomInt]; } static getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } } exports.Balancer = Balancer; //# sourceMappingURL=Balancer.js.map