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