diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-09-09 20:01:04 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-09-09 20:01:04 +0100 |
commit | 749ac8290d1e3d09e2287056f618d6df91f4e01b (patch) | |
tree | b88abc0b15c54708d376bf35c0b8b1575dcb7d0b /src/gleam_stdlib.js | |
parent | ae269282095ba1180952dd1eab58830bf5a19ed2 (diff) | |
download | gleam_stdlib-749ac8290d1e3d09e2287056f618d6df91f4e01b.tar.gz gleam_stdlib-749ac8290d1e3d09e2287056f618d6df91f4e01b.zip |
JS dynamic bool
Diffstat (limited to 'src/gleam_stdlib.js')
-rw-r--r-- | src/gleam_stdlib.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gleam_stdlib.js b/src/gleam_stdlib.js index cfe26a2..b8feecf 100644 --- a/src/gleam_stdlib.js +++ b/src/gleam_stdlib.js @@ -476,8 +476,11 @@ function classify_dynamic(data) { return "List"; } else if (Number.isInteger(data)) { return "Int"; + } else if (typeof data === "number") { + return "Float"; } else { - return typeof data; + let type = typeof data; + return type.charAt(0).toUpperCase() + type.slice(1); } } @@ -498,3 +501,6 @@ export function decode_int(data) { export function decode_float(data) { return typeof data === "number" ? new Ok(data) : decoder_error("Float", data); } +export function decode_bool(data) { + return typeof data === "boolean" ? new Ok(data) : decoder_error("Bool", data); +} |