UNPKG

@benev/slate

Version:
16 lines 429 B
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