
jsMain.js.core.JsTuple.kt Maven / Gradle / Ivy
@file:Suppress(
"DECLARATION_CANT_BE_INLINED",
"NOTHING_TO_INLINE",
)
package js.core
sealed external interface JsTuple {
@JsName("length")
val size: Int
}
sealed interface JsTuple1 : JsTuple {
inline operator fun component1(): A = asDynamic()[0]
}
sealed interface JsTuple2 : JsTuple1 {
inline operator fun component2(): B = asDynamic()[1]
}
sealed interface JsTuple3 : JsTuple2 {
inline operator fun component3(): C = asDynamic()[2]
}
sealed interface JsTuple4 : JsTuple3 {
inline operator fun component4(): D = asDynamic()[3]
}
sealed interface JsTuple5 : JsTuple4 {
inline operator fun component5(): E = asDynamic()[4]
}
inline fun emptyTuple(): JsTuple =
emptyArray()
.unsafeCast()
inline fun tupleOf(
first: A,
): JsTuple1 =
arrayOf(first)
.unsafeCast>()
inline fun tupleOf(
first: A,
second: B,
): JsTuple2 =
arrayOf(first, second)
.unsafeCast>()
inline fun tupleOf(
first: A,
second: B,
third: C,
): JsTuple3 =
arrayOf(first, second, third)
.unsafeCast>()
inline fun tupleOf(
first: A,
second: B,
third: C,
fourth: D,
): JsTuple4 =
arrayOf(first, second, third, fourth)
.unsafeCast>()
inline fun tupleOf(
first: A,
second: B,
third: C,
fourth: D,
fifth: E,
): JsTuple5 =
arrayOf(first, second, third, fourth, fifth)
.unsafeCast>()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy