@benev/slate
Version:
frontend web stuff
16 lines • 429 B
JavaScript
export class Hat {
items;
#content = [];
constructor(items) {
this.items = items;
this.#content = [...items];
}
pull() {
if (this.#content.length === 0)
this.#content = [...this.items];
const index = Math.floor(Math.random() * this.#content.length);
const [item] = this.#content.splice(index, 1);
return item;
}
}
//# sourceMappingURL=hat.js.map