mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 16:35:13 +00:00
Update std.js
This commit is contained in:
parent
b3e4ddc8d1
commit
565175f63c
22
lib/std.js
22
lib/std.js
|
@ -90,15 +90,13 @@ function sleep(ms, callback) {
|
|||
var end = cur + ms;
|
||||
|
||||
if (typeof WScript !== "undefined") {
|
||||
/*
|
||||
while (cur < end) {
|
||||
//WScript.Sleep(1);
|
||||
WScript.Sleep(1);
|
||||
cur = Date.now();
|
||||
}
|
||||
end = Date.now();
|
||||
*/
|
||||
|
||||
WScript.Sleep(ms);
|
||||
|
||||
//WScript.Sleep(ms);
|
||||
if (typeof callback === "function")
|
||||
callback()
|
||||
;
|
||||
|
@ -111,7 +109,7 @@ function sleep(ms, callback) {
|
|||
return { 'ms': end, 'handler': handler };
|
||||
};
|
||||
|
||||
function repeat(target, callback, onError) {
|
||||
function repeat(target, callback, onError, onNextInterval) {
|
||||
switch (typeof target) {
|
||||
case "number":
|
||||
case "boolean":
|
||||
|
@ -143,6 +141,18 @@ function repeat(target, callback, onError) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if use the next interval function
|
||||
if (typeof onNextInterval === "function") {
|
||||
var nextInterval = onNextInterval();
|
||||
if (typeof nextInterval === "number") {
|
||||
var nextEnd = cur + nextInterval;
|
||||
while (cur < nextEnd) {
|
||||
WScript.Sleep(1);
|
||||
cur = Date.now();
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = Date.now();
|
||||
}
|
||||
end = Date.now();
|
||||
|
|
Loading…
Reference in New Issue
Block a user