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

17 lines
307 B
JavaScript

1 year ago
/**
* 作者tmzdy
* 延时操作
* @param {Number} wait = [500] 延时
*/
function sleep(wait=500){
let timid = null;
if(wait==0) return Promise.resolve(true)
clearTimeout(timid);
return new Promise((res,rej)=>{
timid = setTimeout(function() {
res();
}, wait);
})
}
export default sleep;