0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 07:16:56 -05:00
denoland-deno/util.ts

27 lines
810 B
TypeScript
Raw Normal View History

2018-05-14 01:30:56 -04:00
// 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");
2018-05-14 03:12:36 -04:00
const print = V8Worker2.print;
2018-05-14 01:30:56 -04:00
_global["console"] = {
2018-05-14 03:06:09 -04:00
// tslint:disable-next-line:no-any
2018-05-14 01:30:56 -04:00
log(...args: any[]): void {
const out: string[] = [];
2018-05-14 03:06:09 -04:00
for (const a of args) {
2018-05-14 01:30:56 -04:00
if (typeof(a) === "string") {
out.push(a);
} else {
out.push(JSON.stringify(a));
}
}
2018-05-14 03:12:36 -04:00
print(out.join(" "));
2018-05-14 01:30:56 -04:00
}
};