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.mjs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs
index 97fa491..b4f3d22 100644
--- a/src/gleam_stdlib.mjs
+++ b/src/gleam_stdlib.mjs
@@ -210,7 +210,7 @@ export function bit_string_to_string(bit_string) {
let decoder = new TextDecoder("utf-8", { fatal: true });
return new Ok(decoder.decode(bit_string.buffer));
} catch (_error) {
- return new Error(undefined);
+ return new Error(Nil);
}
}
@@ -239,7 +239,13 @@ export function truncate(float) {
}
export function power(base, exponent) {
- return Math.pow(base, exponent);
+ // It is checked in Gleam that:
+ // - The base is non-negative and that the exponent is not fractional.
+ // - The base is not zero and the exponent is not negative (otherwise
+ // the result will essentially be divion 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)
}
export function random_uniform() {