Update std.js

This commit is contained in:
Namhyeon Go 2022-10-21 10:46:30 +09:00 committed by GitHub
parent 3090623121
commit 0ed6697c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();