Update fakeworker.js

This commit is contained in:
Namhyeon Go 2022-10-28 02:12:33 +09:00
parent de8d37bc57
commit 5de1ae1df5

View File

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