aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gleam_stdlib.mjs')
-rw-r--r--src/gleam_stdlib.mjs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs
index 8a2d88f..a3e6c13 100644
--- a/src/gleam_stdlib.mjs
+++ b/src/gleam_stdlib.mjs
@@ -95,7 +95,7 @@ export function string_length(string) {
export function graphemes(string) {
return List.fromArray(
- Array.from(graphemes_iterator(string)).map(((item) => item.segment ))
+ Array.from(graphemes_iterator(string)).map((item) => item.segment)
);
}
@@ -199,12 +199,12 @@ export function bit_string_concat(bit_strings) {
return toBitString(bit_strings.toArray().map((b) => b.buffer));
}
-export function log(term) {
+export function console_log(term) {
console.log(term);
}
-export function debug(term) {
- console.log(inspect(term));
+export function console_error(term) {
+ console.error(term);
}
export function crash(message) {
@@ -228,7 +228,7 @@ export function print(string) {
}
}
-export function eprint(string) {
+export function print_error(string) {
if (typeof process === "object") {
process.stderr.write(string); // We can write without a trailing newline
} else {
@@ -236,6 +236,14 @@ export function eprint(string) {
}
}
+export function print_debug(string) {
+ if (typeof process === "object") {
+ process.stderr.write(string + "\n"); // If we're in Node.js, use `stderr`
+ } else {
+ console.log(string); // Otherwise, use `console.log` (so that it doesn't look like an error)
+ }
+}
+
export function ceiling(float) {
return Math.ceil(float);
}
@@ -259,7 +267,7 @@ export function power(base, exponent) {
// the result will essentially be division by zero).
// It can thus be assumed that valid input is passed to the Math.pow
// function and a NaN or Infinity value will not be produced.
- return Math.pow(base, exponent)
+ return Math.pow(base, exponent);
}
export function random_uniform() {