mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Added AsyncFunction class
This commit is contained in:
parent
07245f89cf
commit
caa57b91e4
20
app.js
20
app.js
|
@ -77,14 +77,14 @@ var console = {
|
|||
WScript.echo(" * " + message)
|
||||
}
|
||||
this._messages.push(message);
|
||||
params.message = message;
|
||||
params.message = message;
|
||||
} else if (typeof args[0] === "object") {
|
||||
if ('message' in args[0]) {
|
||||
if (typeof type !== "undefined") {
|
||||
message += (type + ": " + args[0].message);
|
||||
} else {
|
||||
message += args[0].message;
|
||||
}
|
||||
if (typeof type !== "undefined") {
|
||||
message += (type + ": " + args[0].message);
|
||||
} else {
|
||||
message += args[0].message;
|
||||
}
|
||||
}
|
||||
if (typeof WScript !== "undefined") {
|
||||
WScript.echo(" * " + message);
|
||||
|
@ -98,7 +98,13 @@ var console = {
|
|||
|
||||
// after calling echo
|
||||
if (['error', 'info', 'warn'].indexOf(type) > -1 && typeof this._echoCallback === "function") {
|
||||
this._echoCallback(params);
|
||||
try {
|
||||
this._echoCallback(params);
|
||||
} catch (e) {
|
||||
if (typeof WScript !== "undefined") {
|
||||
WScript.echo(" * Exception of _echoCallback:", e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
assert: function(assertion) {
|
||||
|
|
|
@ -213,6 +213,10 @@ function includeFile(FN) {
|
|||
eval(fileData);
|
||||
}
|
||||
|
||||
function appendFile(FN, content, charset) {
|
||||
return writeFile(FN, readFile(FN, charset) + content, charset);
|
||||
}
|
||||
|
||||
exports.fileExists = fileExists;
|
||||
exports.folderExists = folderExists;
|
||||
exports.fileGet = fileGet;
|
||||
|
@ -224,3 +228,4 @@ exports.createFolder = createFolder;
|
|||
exports.deleteFolder = deleteFolder;
|
||||
exports.deleteFile = deleteFile;
|
||||
exports.includeFile = includeFile;
|
||||
exports.appendFile = appendFile;
|
13
lib/std.js
13
lib/std.js
|
@ -306,6 +306,16 @@ function StdEventableObject() {
|
|||
};
|
||||
};
|
||||
|
||||
function AsyncFunction(f) {
|
||||
this.f = f;
|
||||
this.run = function() {
|
||||
sleep(1, this.f);
|
||||
};
|
||||
this.runSynchronously = function() {
|
||||
return this.f();
|
||||
};
|
||||
};
|
||||
|
||||
global.GetResource = GetResource;
|
||||
global.sleep = sleep;
|
||||
global.repeat = repeat;
|
||||
|
@ -314,10 +324,11 @@ global.range = range;
|
|||
global.CHR = CHR;
|
||||
global.splitLn = splitLn;
|
||||
global.addslashes = addslashes;
|
||||
global.AsyncFunction = AsyncFunction;
|
||||
|
||||
exports.VERSIONINFO = "Standard Lib (std.js) version 0.4";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
exports.Event = StdEvent;
|
||||
exports.EventableObject = StdEventableObject;
|
||||
exports.EventableObject = StdEventableObject;
|
|
@ -39,8 +39,8 @@ var WebsocketObject = function() {
|
|||
this.binPath,
|
||||
"-n1",
|
||||
"-t",
|
||||
"--ping-timeout",
|
||||
1,
|
||||
//"--ping-timeout",
|
||||
//1,
|
||||
uri,
|
||||
"<",
|
||||
FN
|
||||
|
|
Loading…
Reference in New Issue
Block a user