From f9c1b62d60bf4c977790c6e9344da7e559a90930 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 22 Feb 2024 14:33:04 -0700 Subject: [PATCH] add wait method to Queue --- src/utils/queue.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/queue.js b/src/utils/queue.js index aeb7943..85e4449 100644 --- a/src/utils/queue.js +++ b/src/utils/queue.js @@ -36,6 +36,11 @@ export default class Queue { } } } + + // pushes a delay of `delay` ms to the end of the queue + wait (delay) { + return this.enqueue_and_wait(() => new Promise((resolve => setTimeout(resolve, delay)))) + } async close() { // This code path is not currently used. If it doesn't work as expected, don't be too surprised