Updated the sleep function to runAfter
- Added async - Allowed functions to be run with it - Added logging
This commit is contained in:
@@ -5,9 +5,10 @@ const log = new DebugBuilder("server", "libUtils");
|
|||||||
* sleep - sleep/wait
|
* sleep - sleep/wait
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
exports.sleep = (ms) => new Promise((resolve) => {
|
exports.runAfter = async (toRun, timeout = 10000) => {
|
||||||
setTimeout(resolve, ms);
|
log.DEBUG(`Running '${toRun}' after ${timeout / 1000} seconds`);
|
||||||
})
|
setTimeout(toRun, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize a port into a number, string, or false.
|
* Normalize a port into a number, string, or false.
|
||||||
|
|||||||
Reference in New Issue
Block a user