Formerly andreasewering/elm-protoc-utils. Search finds this package by either name.
Utility methods for Int64 needed in the Protobuf/gRPC context.
Interpret a Int64 as an unsigned integer, and give its string representation
toUnsignedString (fromInt 10)
--> "10"
toUnsignedString (fromInt -10)
--> "18446744073709551606"Parse a signed Int64 from its string representation
fromSignedString "10"
--> Just (Int64 { higher = 0, lower = 10 })
fromSignedString "-10"
--> Just (Int64 { higher = -1, lower = -10 })
fromSignedString "not-a-number"
--> Nothing
fromSignedString "9223372036854775807"
--> Just (Int64 { higher = 2147483647, lower = -1 })
fromSignedString "-9223372036854775808"
--> Just (Int64 { higher = -2147483648, lower = 0 })
fromSignedString "-9223372036854775809"
--> NothingParse an unsigned Int64 from its string representation
fromUnsignedString "10"
--> Just (Int64 { higher = 0, lower = 10 })
fromUnsignedString "-10"
--> Nothing
fromUnsignedString "not-a-number"
--> Nothing
fromUnsignedString "9223372036854775807"
--> Just (Int64 { higher = 2147483647, lower = -1 })
fromUnsignedString "18446744073709551615"
--> Just (Int64 { higher = -1, lower = -1 })
fromUnsignedString "18446744073709551616"
--> NothingConstructs an Int64 from an Int. The Int can be bigger than 32-bit, you can expect Integers in the safe int range in JS (-(2^53 - 1) to 2^53 - 1) to work.
Attempts to convert the Int64 into a JS Int. This should be safe for the safe int range in JS (-(2^53 - 1) to 2^53 - 1). Expect weird results for anything outside that range.
Decodes an Int64 from a signed integer JSON string (i.e. {"key": "-123456789"}) or a JSON number literal (i.e. {"key": -123})
Decodes an Int64 from an unsigned integer JSON string (i.e. {"key": "123456789"}) or a JSON number literal (i.e. {"key": 123})
Encodes an Int64 as a signed integer JSON string
Encodes an Int64 as an unsigned integer JSON string
Interpret a
Int64as an unsigned integer, and give its string representation.