I ran into <an issue> in Compose for Desktop where...
# javascript
e
I ran into an issue in Compose for Desktop where a function isn't implemented in the js source set:
Copy code
internal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int): Unit =
   TODO("implement js ByteArray.putBytesInto()")
The jvm implementation is:
Copy code
internal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int) {
    ByteBuffer.wrap(this)
        .order(ByteOrder.LITTLE_ENDIAN) // to return ARGB
        .asIntBuffer()
        .get(array, offset, length)
}
Would the following be a correct implementation (even if not optimal):
Copy code
internal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int) {
  val byteBuffer = Uint8Array(this.toTypedArray()).buffer
  val intArray = Int32Array(byteBuffer, offset, length)
  for(i in 0 until intArray.length) {
    array[i] = intArray[i]
  }
}
t
AFAIK
ByteArray
is
Uint8Array
alias
e
Oh cool, I'll try calling
buffer
directly