aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.js
diff options
context:
space:
mode:
authorPeter Saxton <peterhsaxton@gmail.com>2021-07-20 11:54:19 +0100
committerGitHub <noreply@github.com>2021-07-20 11:54:19 +0100
commit363d0a0c95fc1f3c91fe5c1101cac9d848c66fde (patch)
treee620eac17243e268ade54206aa7bd1995ede5732 /src/gleam_stdlib.js
parentd2ff5bec0c60fc748aa8c5c7ef7793430e1b1db2 (diff)
downloadgleam_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.js19
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