diff options
Diffstat (limited to 'src/client/Native')
-rw-r--r-- | src/client/Native/Reads.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/client/Native/Reads.js b/src/client/Native/Reads.js new file mode 100644 index 0000000..52590f9 --- /dev/null +++ b/src/client/Native/Reads.js @@ -0,0 +1,27 @@ +Elm.Native.Reads = {}; +Elm.Native.Reads.make = function(localRuntime) { + + localRuntime.Native = localRuntime.Native || {}; + localRuntime.Native.Reads = localRuntime.Native.Reads || {}; + if(localRuntime.Native.Reads.values) { + return localRuntime.Native.Reads.values; + } + + var Result = Elm.Result.make(localRuntime); + + function div(a, b) + { + return (a/b)|0; + } + + function readInt(str) { + var number = Number(str); + return isNaN(number) + ? Result.Err("unable to parse '" + str + "' as a number") + : Result.Ok(number); + } + + return localRuntime.Native.Reads.values = { + readInt: readInt + }; +}; |