const { Queue } = require("async-await-queue"); class Scrobbler { #queue = null; #logger = null; constructor(logger) { this.#queue = new Queue(1, 300); this.#logger = logger; } async queue(media, duration, start) { const id = Symbol(); try { await this.#queue.wait(id, 0); await this.scrobble(media, duration, start); } catch (ex) { this.#logger.console.error(media, "Failed to scrobble: " + ex.message); } finally { this.#queue.end(id, duration, start); } } async scrobble(media, duration, start) { console.log("This should not be running, ever."); } } module.exports = Scrobbler;