Merge pull request #13 from alolimous/feature/setInterval

add setInterval
This commit is contained in:
Hao 2022-08-18 15:15:48 +09:00 committed by GitHub
commit 50ec0e732b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,9 +78,13 @@ const lodash = typeof require !== 'undefined' ? require('lodash') : {};
* @zh setTimeout总是会比预期时间慢1秒才触发
*/
const _timeout = global.setTimeout;
const _interval = global.setInterval;
global.setTimeout = function (handler, timeout, ...args) {
return _timeout.call(global, handler, +timeout + 1000, ...args);
}
global.setInterval = function (handler, timeout, ...args) {
return _interval.call(global, handler, +timeout + 1000, ...args);
}
/**
* Promise.then has a 10% chance will not trigger