You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

12 lines
337 B

class TimeUtil {
static sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// nodeJs 是单线程的 使用该函数需要谨慎操作 推荐使用 sleep + async/await
static sleepSync(ms) {
const start = Date.now();
while (Date.now() - start < ms) {
}
}
}
module.exports = TimeUtil;