diff options
author | Louis Pilfold <louis@lpil.uk> | 2021-09-09 19:52:22 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-09-09 19:52:22 +0100 |
commit | 014cf4a208b254d2172f318147edccc70fc1e49d (patch) | |
tree | b9bb3d9d0b07447b3f9f9623d657e35065748202 /src/gleam_stdlib.js | |
parent | c45c1038f8b12acf7d2010eba070ad3dc54765a2 (diff) | |
download | gleam_stdlib-014cf4a208b254d2172f318147edccc70fc1e49d.tar.gz gleam_stdlib-014cf4a208b254d2172f318147edccc70fc1e49d.zip |
JS dynamic int and float
Diffstat (limited to 'src/gleam_stdlib.js')
-rw-r--r-- | src/gleam_stdlib.js | 8 |
1 files changed, 8 insertions, 0 deletions
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); +} |