[Wasm] Move ItemArrayLike w3c declarations into the right package
This commit is contained in:
@@ -13,17 +13,3 @@ internal val undefined: Nothing? = null
|
|||||||
*/
|
*/
|
||||||
@JsFun("(s) => eval(s)")
|
@JsFun("(s) => eval(s)")
|
||||||
external fun js(code: String): Dynamic
|
external fun js(code: String): Dynamic
|
||||||
|
|
||||||
external interface ItemArrayLike<out T> {
|
|
||||||
val length: Int
|
|
||||||
fun item(index: Int): T?
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> ItemArrayLike<T>.asList(): List<T> = object : AbstractList<T>() {
|
|
||||||
override val size: Int get() = this@asList.length
|
|
||||||
|
|
||||||
override fun get(index: Int): T = when (index) {
|
|
||||||
in 0..lastIndex -> this@asList.item(index) as T
|
|
||||||
else -> throw IndexOutOfBoundsException("index $index is not in range [0..$lastIndex]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.w3c.dom
|
||||||
|
|
||||||
|
public external interface ItemArrayLike<out T> {
|
||||||
|
val length: Int
|
||||||
|
fun item(index: Int): T?
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <T> ItemArrayLike<T>.asList(): List<T> = object : AbstractList<T>() {
|
||||||
|
override val size: Int get() = this@asList.length
|
||||||
|
|
||||||
|
override fun get(index: Int): T = when (index) {
|
||||||
|
in 0..lastIndex -> this@asList.item(index) as T
|
||||||
|
else -> throw IndexOutOfBoundsException("index $index is not in range [0..$lastIndex]")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user