diff options
author | brettkolodny <brettkolodny@gmail.com> | 2023-02-17 10:15:19 -0500 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-02-18 10:39:40 +0000 |
commit | b351a2e3766ca9bc64039ee455bb1da5cfa65867 (patch) | |
tree | d9def8efeaceea92523aa40395641b0b9c43c4b8 /src/gleam_stdlib.mjs | |
parent | db350eaf0eb4cefe86f19e553b5637bce442c3c2 (diff) | |
download | gleam_stdlib-b351a2e3766ca9bc64039ee455bb1da5cfa65867.tar.gz gleam_stdlib-b351a2e3766ca9bc64039ee455bb1da5cfa65867.zip |
fix: deno print_error and print_debug to match node implementation
Diffstat (limited to 'src/gleam_stdlib.mjs')
-rw-r--r-- | src/gleam_stdlib.mjs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index 8532821..60ab625 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -276,7 +276,7 @@ export function print(string) { if (typeof process === "object") { process.stdout.write(string); // We can write without a trailing newline } else if (typeof Deno === "object") { - Deno.stdout.writeSync(new TextEncoder().encode(string)); + Deno.stdout.writeSync(new TextEncoder().encode(string)); // We can write without a trailing newline } else { console.log(string); // We're in a browser. Newlines are mandated } @@ -285,6 +285,8 @@ export function print(string) { export function print_error(string) { if (typeof process === "object") { process.stderr.write(string); // We can write without a trailing newline + } else if (typeof Deno === "object") { + Deno.stderr.writeSync(new TextEncoder().encode(string)); // We can write without a trailing newline } else { console.error(string); // We're in a browser. Newlines are mandated } @@ -293,6 +295,8 @@ export function print_error(string) { export function print_debug(string) { if (typeof process === "object") { process.stderr.write(string + "\n"); // If we're in Node.js, use `stderr` + } else if (typeof Deno === "object") { + Deno.stderr.writeSync(new TextEncoder().encode(string + "\n")); // If we're in Deno, use `stderr` } else { console.log(string); // Otherwise, use `console.log` (so that it doesn't look like an error) } |