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