mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Update fakeworker.js
This commit is contained in:
parent
de8d37bc57
commit
5de1ae1df5
|
@ -15,7 +15,7 @@ function FakeWorker() {
|
|||
}
|
||||
};
|
||||
|
||||
this.btoa = function(stringToEncode)
|
||||
this.btoa = function(stringToEncode) {
|
||||
if (!this.__isWindow__) {
|
||||
return BASE64.encode(stringToEncode);
|
||||
} else {
|
||||
|
@ -117,7 +117,33 @@ exports.create = function() {
|
|||
return new FakeWorker();
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "FakeWorker module (fakeworker.js) version 0.0.1";
|
||||
exports.repeat = function(target, worker) {
|
||||
if (!(worker instanceof FakeWorker)) return;
|
||||
|
||||
if (["number", "boolean"].indexOf(typeof target) > -1) {
|
||||
var ms = target;
|
||||
var cur = Date.now();
|
||||
var end = cur + ms;
|
||||
|
||||
while (ms === true ? true : (cur < end)) {
|
||||
var intervals = worker.getIntervals();
|
||||
for (var i = 0; i < intervals.length; i++) {
|
||||
try {
|
||||
if (typeof intervals[i].code === "function") x.code(i);
|
||||
} catch (e) {
|
||||
if (typeof onError === "function") onError(e, i);
|
||||
}
|
||||
};
|
||||
cur = Date.now();
|
||||
}
|
||||
|
||||
end = Date.now();
|
||||
}
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "FakeWorker module (fakeworker.js) version 0.0.2";
|
||||
exports.AUTHOR = "catswords@protonmail.com";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user