From 5353118642dfee251dc4213ab985118252e517da Mon Sep 17 00:00:00 2001 From: mizukiwei Date: Thu, 18 Aug 2022 14:12:31 +0800 Subject: [PATCH 1/2] add setInterval --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index bbe4cd8..6b1282b 100644 --- a/index.js +++ b/index.js @@ -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.setTimeout = function (handler, timeout, ...args) { + return _interval.call(global, handler, +timeout + 1000, ...args); + } /** * Promise.then has a 10% chance will not trigger From 7a4322eb01868a9c70df9e8b59438493884d63b2 Mon Sep 17 00:00:00 2001 From: mizukiwei Date: Thu, 18 Aug 2022 14:14:58 +0800 Subject: [PATCH 2/2] fix func --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 6b1282b..d838ed3 100644 --- a/index.js +++ b/index.js @@ -82,7 +82,7 @@ const lodash = typeof require !== 'undefined' ? require('lodash') : {}; global.setTimeout = function (handler, timeout, ...args) { return _timeout.call(global, handler, +timeout + 1000, ...args); } - global.setTimeout = function (handler, timeout, ...args) { + global.setInterval = function (handler, timeout, ...args) { return _interval.call(global, handler, +timeout + 1000, ...args); }