ultrax
Version:
UltraX Package is a unique package that allows you to create cool things using simple functions and make it faster, for example there is an invite logger, discord buttons paginator, etc...
20 lines (18 loc) • 466 B
JavaScript
/**
* Sleep-based Timeout function
* @param {Number} milliseconds Sleep time (ms)
* @returns {Promise<void>}
*/
function sleep(milliseconds) {
if (!milliseconds) throw new TypeError("Time isn't specified")
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
module.exports = sleep;
/**
* const wait = require('util').promisify(setTimeout)
* wait(5000)
*/