From 014cf4a208b254d2172f318147edccc70fc1e49d Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 9 Sep 2021 19:52:22 +0100 Subject: JS dynamic int and float --- src/gleam_stdlib.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gleam_stdlib.js') diff --git a/src/gleam_stdlib.js b/src/gleam_stdlib.js index 75b0882..cfe26a2 100644 --- a/src/gleam_stdlib.js +++ b/src/gleam_stdlib.js @@ -490,3 +490,11 @@ export function decode_string(data) { ? new Ok(data) : decoder_error("String", data); } + +export function decode_int(data) { + return Number.isInteger(data) ? new Ok(data) : decoder_error("Int", data); +} + +export function decode_float(data) { + return typeof data === "number" ? new Ok(data) : decoder_error("Float", data); +} -- cgit v1.2.3