Skip to content

Commit

Permalink
utils中添加了一个随机定时的setTimeout_random
Browse files Browse the repository at this point in the history
  • Loading branch information
ihrskyfish committed Sep 1, 2024
1 parent 599c90f commit 8a08e3c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/myUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ var area = function (r) {
return PI * r * r;
};
var circumference = function (r) { return 2 * PI * r; };
export { area, circumference };
function setTimeout_random(callback, minMilliseconds=0, maxMilliseconds=8 * 60 * 60 * 1000) {
const randomDelay = Math.floor(Math.random() * (maxMilliseconds - minMilliseconds + 1)) + minMilliseconds;
// 使用 setTimeout 在随机时间间隔后执行回调函数
setTimeout(callback, randomDelay);
}


export { area, circumference ,setTimeout_random};

0 comments on commit 8a08e3c

Please sign in to comment.