diff --git a/lib/std.js b/lib/std.js index 1a42aa1..a24f53c 100644 --- a/lib/std.js +++ b/lib/std.js @@ -109,7 +109,7 @@ function sleep(ms, callback) { return { 'ms': end, 'handler': handler }; }; -function repeat(target, callback, onError, onNextInterval) { +function repeat(target, callback, onError, onNextInterval, onNext) { switch (typeof target) { case "number": case "boolean": @@ -142,7 +142,7 @@ function repeat(target, callback, onError, onNextInterval) { } } - // if use the next interval function + // if use onNextInterval method if (typeof onNextInterval === "function") { var nextInterval = onNextInterval(); if (typeof nextInterval === "number") { @@ -153,6 +153,15 @@ function repeat(target, callback, onError, onNextInterval) { } } } + + // if use onNext method + if (typeof onNext === "function") { + try { + onNext(); + } catch (e) {} + } + + // set the last time cur = Date.now(); } end = Date.now();