square / okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
https://square.github.io/okio/
Apache License 2.0
8.76k stars 1.18k forks source link

Add APIs for working with JS types #689

Open JakeWharton opened 4 years ago

JakeWharton commented 4 years ago

ArrayBuffer, UInt8Array, etc.

swankjesse commented 4 years ago

Yes!

JakeWharton commented 4 years ago

Probably

Currently just cheating with:

private fun ArrayBuffer.toByteString(): ByteString {
  val uint8Array = Uint8Array(this)
  val buffer = Buffer()
  for (i in 0 until uint8Array.length) {
    buffer.writeByte(uint8Array[i].toInt())
  }
  return buffer.readByteString()
}