simple implementation of await

This commit is contained in:
Jonathan Rainville 2018-08-22 11:32:15 -04:00
parent b4e118c85b
commit 8ebe55f457
1 changed files with 4 additions and 0 deletions

View File

@ -41,6 +41,10 @@ class CodeRunner {
if (!cb) {
cb = function() {};
}
if (code.startsWith('await')) {
code = code.substring(5); // remove await keyword
code += '.then(console.log).catch(console.error)'; // Add promise catch
}
let result = RunCode.doEval(code);
if (forConsoleOnly && self.ipc.isServer()) {
self.commands.push({code});