Hello everyone, is there a simpler way of reading...
# javascript
z
Hello everyone, is there a simpler way of reading an ArrayBuffer to a ByteArray than this?
Copy code
Int8Array(data as ArrayBuffer).let {
    ByteArray(it.length){ i ->
        it[i]
    }
}
Use case: I am using CBOR and plain ByteArrays to communicate via websocket.
✔️ 1
🧵 1
d
Last I checked, you can just cast and it'll work
👍 2
val res: ByteArray = Int8Array(data as ArrayBuffer).unsafeCast()
z
Ah, thanks!