Jorrit
08/05/2020, 12:37 AMjoin()
to `Uint16Array`:
@JsName("Uin16Array")
public external open class Uint16ArrayX : Uint16Array {
// copy/paste constructors from Uint16Array here
fun join(separator: String = definedExternally): String
}
This seems to work, but it also feels like I need to wash my hands now. I can use an Uint16ArrayX
anywhere a Uint16Array
is asked for. The only caveat is that going from X to original needs an unsafeCast, but that is mildly inconvenient at worst.
I didn't find a way to patch Uint16Array directly. The compiler wont accept external extensions to an external class. Is there a better way to do this than above? Ofcourse I could just (Uint16Array).asDynamic().join(...) but that's not the point of this exercise.
(b) It seems CharArray uses Uint16Array internally (IntArray to Int32Array, etc), but am I correct in my understanding that CharArray's functions are otherwise pure kotlin and not (or rarely) mapped to their Uint16Array counterparts (which aren't declared at this point anyway) ?
(c) For TypedArrays (and a few other things) it seems Kotlin's definitions are a bit outdated/missing. I looked in Kotlin source GitHub to see if I might contribute at some point, but it is unclear to me what comes from where. There's idl files referenced to which the original urls no longer serve (are the kotlin files autogenerated from them .idl or hand-translated?). There are several copies of the definitions as well. Where to start here for possible (far) future pull request ?andylamax
08/05/2020, 1:27 AMinline fun Uint16Array.join(separator: String = ",") : String = asDynamic().join(separator)
???Jorrit
08/05/2020, 8:24 AMandylamax
08/08/2020, 5:27 AM