diff options
author | Peter Saxton <peterhsaxton@gmail.com> | 2021-07-20 11:54:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 11:54:19 +0100 |
commit | 363d0a0c95fc1f3c91fe5c1101cac9d848c66fde (patch) | |
tree | e620eac17243e268ade54206aa7bd1995ede5732 /src/gleam_stdlib.js | |
parent | d2ff5bec0c60fc748aa8c5c7ef7793430e1b1db2 (diff) | |
download | gleam_stdlib-363d0a0c95fc1f3c91fe5c1101cac9d848c66fde.tar.gz gleam_stdlib-363d0a0c95fc1f3c91fe5c1101cac9d848c66fde.zip |
Port int module to JS (#219)
Diffstat (limited to 'src/gleam_stdlib.js')
-rw-r--r-- | src/gleam_stdlib.js | 19 |
1 files changed, 19 insertions, 0 deletions
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 |