Update std.js

This commit is contained in:
Namhyeon Go 2022-02-08 19:58:39 +09:00 committed by GitHub
parent 7f12616acf
commit 109aecf680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,8 +102,11 @@ function sleep(ms, callback) {
function repeat(target, callback, onError) {
switch (typeof target) {
case "number":
case "boolean":
case "boolean":
var ms = target;
var i = 0;
var n = 0;
var handler = null;
var cur = Date.now();
var end = cur + ms;
@ -112,7 +115,10 @@ function repeat(target, callback, onError) {
while (ms === true ? true : (cur < end)) {
try {
if (typeof callback === "function")
callback(cur)
var n = callback(i);
if (typeof n === "number")
i += n
;
;
} catch (e) {
if (typeof onError === "function")