From 749ac8290d1e3d09e2287056f618d6df91f4e01b Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 9 Sep 2021 20:01:04 +0100 Subject: JS dynamic bool --- src/gleam_stdlib.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gleam_stdlib.js') 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); +} -- cgit v1.2.3