Comments.

master
Philippe Pittoli 2023-05-20 00:36:17 +02:00
parent ca93e11fb4
commit 20ba8f9144
1 changed files with 3 additions and 1 deletions

View File

@ -49,10 +49,12 @@ utf8ToArrayBuffer s = Builder.execPutM do
toIPC :: String -> Effect ArrayBuffer toIPC :: String -> Effect ArrayBuffer
toIPC = utf8ToArrayBuffer toIPC = utf8ToArrayBuffer
-- TODO: this code shouldn't handle parse errors.
fromIPC :: ArrayBuffer -> Effect (Either ParseError String) fromIPC :: ArrayBuffer -> Effect (Either ParseError String)
fromIPC = arrayBufferToUtf8 fromIPC = arrayBufferToUtf8
-- TODO: this code doesn't verify the actual length of the message.
-- An inconsistent length would be an error sign, message should be discarded
-- and the connection should be closed.
arrayBufferToUtf8 :: ArrayBuffer -> Effect (Either ParseError String) arrayBufferToUtf8 :: ArrayBuffer -> Effect (Either ParseError String)
arrayBufferToUtf8 arrayBuffer = do arrayBufferToUtf8 arrayBuffer = do
textDecoder <- TextDecoder.new UtfLabel.utf8 textDecoder <- TextDecoder.new UtfLabel.utf8