diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2018-06-05 01:22:39 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-06-11 17:49:52 +0200 |
commit | cc29542ad87fba6d605e65f468f1943bf8e200cb (patch) | |
tree | 36b5c4ff43481e3b40bde9a01ccc2b8806769cfe /globals.ts | |
parent | 9800339439d7ecffc8aa6e746643b75d4e23ea17 (diff) |
Improve console and stringify.
Diffstat (limited to 'globals.ts')
-rw-r--r-- | globals.ts | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/globals.ts b/globals.ts index 896c2a0eb..cca72d172 100644 --- a/globals.ts +++ b/globals.ts @@ -21,39 +21,8 @@ _global["setInterval"] = timer.setInterval; _global["clearTimeout"] = timer.clearTimer; _global["clearInterval"] = timer.clearTimer; -const print = V8Worker2.print; - -_global["console"] = { - // tslint:disable-next-line:no-any - log(...args: any[]): void { - print(stringifyArgs(args)); - }, - - // tslint:disable-next-line:no-any - error(...args: any[]): void { - print(`ERROR: ${stringifyArgs(args)}`); - }, - - // tslint:disable-next-line:no-any - assert(condition: boolean, ...args: any[]): void { - if (!condition) { - throw new Error(`Assertion failed: ${stringifyArgs(args)}`); - } - } -}; - -// tslint:disable-next-line:no-any -function stringifyArgs(args: any[]): string { - const out: string[] = []; - for (const a of args) { - if (typeof a === "string") { - out.push(a); - } else { - out.push(JSON.stringify(a)); - } - } - return out.join(" "); -} +import { Console } from "./console"; +_global["console"] = new Console(); import { fetch } from "./fetch"; _global["fetch"] = fetch; |