I have a Seq[Byte]
that I need to convert to js.Iterable[Byte]
. I have some code that does that task:
import scala.scalajs.js
import scalajs.js.JSConverters.iterableOnceConvertible2JSRichIterableOnce
val src: Seq[Byte] = Seq(1, 2, 3)
val target: js.Iterable[Byte] = src.toJSArray
This code works but is likely not very efficient. Can target
be created lazily without full array creation via toJSArray
?
toJSIterable
, provided by JSConverters
, does exactly what you want:
import scala.scalajs.js
import scala.scalajs.js.JSConverters._
val src: Seq[Byte] = Seq(1, 2, 3)
val target: js.Iterable[Byte] = src.toJSIterable