summaryrefslogtreecommitdiff
path: root/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'util.ts')
-rw-r--r--util.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/util.ts b/util.ts
index f5e5e847e..7a6666942 100644
--- a/util.ts
+++ b/util.ts
@@ -13,18 +13,28 @@ const print = V8Worker2.print;
_global["console"] = {
// tslint:disable-next-line:no-any
log(...args: any[]): void {
- const out: string[] = [];
- for (const a of args) {
- if (typeof a === "string") {
- out.push(a);
- } else {
- out.push(JSON.stringify(a));
- }
- }
- print(out.join(" "));
+ print(stringifyArgs(args));
+ },
+
+ // tslint:disable-next-line:no-any
+ error(...args: any[]): void {
+ print("ERROR: " + 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(" ");
+}
+
export function assert(cond: boolean, msg = "") {
if (!cond) {
throw Error("Assertion failed. " + msg);