mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Update std.js
This commit is contained in:
parent
7f12616acf
commit
109aecf680
10
lib/std.js
10
lib/std.js
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user