From 77417da1b4da9ad3192379a3828d39f8437becb3 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Sat, 17 Oct 2020 15:08:26 +0100 Subject: [PATCH] added wait function to helpers --- utils/helpers.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/helpers.js b/utils/helpers.js index 4fecdc2f..9e08e671 100644 --- a/utils/helpers.js +++ b/utils/helpers.js @@ -19,6 +19,13 @@ const asyncFilter = async (arr, cb) => { return arr.filter((_, i) => results[i]) } +const wait = (seconds = 0) => + new Promise(resolve => { + /** @type {NodeJS.Timeout} */ + const timer = setTimeout(() => resolve(timer), seconds * 1000) + }) + module.exports = { - asyncFilter + asyncFilter, + wait }