How do I do conversions of
Bytes.t <-> Uint8Array. I know there is Bytes.to_string , but my encoded bytes is arbitrary
Vec<u8>, not necessairly a valid utf string.
Is the way to do the conversion to go through OCaml string, or is there some other more direct way ?
Thanks! (I tried grepping for
Bytes.t in the js_of_ocaml source but not finding anything useful).
I got something that compiles. It goes:
Bytes.t <-> string <-> Bigstring.t (Bigarray) <-> JS uint8array
This seems awfully redundant. Is there a cleaner solution ?
Create the typed array and set it inside a
Is this a function call per every byte of the Bytes.t ?
I understand C’s memcpy does the same thing, but to be doing/looping this in JS; this sounds awfully slow.
I guess the other side of the argument is – of the 3 conversions I’m currently doing, atleast one is probably iterating in JS and copying byte by byte, so I might as well as just implement it myself and avoid the 3 layers of indirection.