From 363d0a0c95fc1f3c91fe5c1101cac9d848c66fde Mon Sep 17 00:00:00 2001 From: Peter Saxton Date: Tue, 20 Jul 2021 11:54:19 +0100 Subject: Port int module to JS (#219) --- src/gleam_stdlib.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/gleam_stdlib.js') diff --git a/src/gleam_stdlib.js b/src/gleam_stdlib.js index e69de29..960792b 100644 --- a/src/gleam_stdlib.js +++ b/src/gleam_stdlib.js @@ -0,0 +1,19 @@ +export function identity(x) { + return x +} + +export function parse_int(value) { + if (/^[-+]?(\d+)$/.test(value)) { + return { "type": "Ok", "0": Number(value) } + } else { + return { "type": "Error", "0": null } + } +} + +export function int_to_string(int) { + return int.toString() +} + +export function int_to_base_string(int, base) { + return int.toString(base) +} \ No newline at end of file -- cgit v1.2.3