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 11:57:00 +0200 |
| commit | 93654831fe501a4a011610bfc52b2d0fc87eb949 (patch) | |
| tree | 1d3c40fd7db9c3e1dbfd7b27c9bc1e26bc1998de /globals.ts | |
| parent | 4d3e684366395782dfb11acbc05d877121746887 (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; |
