diff options
Diffstat (limited to 'util.ts')
-rw-r--r-- | util.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/util.ts b/util.ts new file mode 100644 index 000000000..467515225 --- /dev/null +++ b/util.ts @@ -0,0 +1,23 @@ +// If you use the eval function indirectly, by invoking it via a reference +// other than eval, as of ECMAScript 5 it works in the global scope rather than +// the local scope. This means, for instance, that function declarations create +// global functions, and that the code being evaluated doesn't have access to +// local variables within the scope where it's being called. +const globalEval = eval; + +// A reference to the global object. +const _global = globalEval("this"); + +_global["console"] = { + log(...args: any[]): void { + const out: string[] = []; + for (let a of args) { + if (typeof(a) === "string") { + out.push(a); + } else { + out.push(JSON.stringify(a)); + } + } + V8Worker2.print(out.join(" ")); + } +}; |