Update std.js

This commit is contained in:
Namhyeon Go 2024-08-06 21:15:59 +09:00 committed by GitHub
parent 69888245bf
commit ca6f13196d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -300,12 +300,8 @@ function confirm(message) {
} }
} }
/////////////////////////////////////////////////////////////////////////////////
// Standard Event Object // Standard Event Object
/////////////////////////////////////////////////////////////////////////////////
// https://developer.mozilla.org/ko/docs/Web/API/Event // https://developer.mozilla.org/ko/docs/Web/API/Event
function StdEvent(type) { function StdEvent(type) {
this.defaultPrevented = false; this.defaultPrevented = false;
this.timeStamp = new Date(); this.timeStamp = new Date();
@ -425,7 +421,7 @@ function AsyncFunction(f, __filename) {
// CLI or Window? // CLI or Window?
if (typeof WScript !== "undefined") { if (typeof WScript !== "undefined") {
require("lib/shell").show(["cscript", "app.js", this.__filename, f].concat(args)); require("lib/shell").show(["cscript", "app.js", this.__filename, "/async", f].concat(args));
} else { } else {
sleep(1, _f); sleep(1, _f);
} }
@ -437,33 +433,29 @@ function AsyncFunction(f, __filename) {
}; };
AsyncFunction.counter = 0; AsyncFunction.counter = 0;
AsyncFunction.bind = function(exports, args) { AsyncFunction.bind = function(exports, args) {
var result = false; if (args.length < 2)
return;
if (args.length > 0) { if (args[0] != "/async")
var targets = [args[0], '_async_' + args[0]]; return;
for (var i = 0; (i < targets.length && result == false); i++) { var target = args[1];
var target = targets[i]; if (target in exports && exports[target] instanceof AsyncFunction) {
if (target in exports && (typeof exports[target] === "function" || exports[target] instanceof AsyncFunction)) {
try { try {
exports[target](args); exports[target].f(args);
result = true;
} catch (e) { } catch (e) {
console.error("Exception of", target, e.message); console.error("Exception on", target, e.message);
}
}
} }
} }
throw new AsyncFunction.TaskDone("AsyncFunction completed"); throw new AsyncFunction.Resolved("Resolved");
}; };
AsyncFunction.TaskDone = function(message) { AsyncFunction.Resolved = function(message) {
this.name = "AsyncFunction.TaskDone"; this.name = "AsyncFunction.Resolved";
this.message = message; this.message = message;
}; };
AsyncFunction.TaskDone.prototype = new Error(); AsyncFunction.Resolved.prototype = new Error();
AsyncFunction.TaskDone.prototype.constructor = AsyncFunction.TaskDone; AsyncFunction.Resolved.prototype.constructor = AsyncFunction.Resolved;
// [app] Transpiling ES6 generator functions #75 // [app] Transpiling ES6 generator functions #75
function GeneratorFunction(f) { function GeneratorFunction(f) {