All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.react.select.Value.kt Maven / Gradle / Ivy

@file:Suppress(
    "DECLARATION_CANT_BE_INLINED",
    "NOTHING_TO_INLINE",
)

package react.select

import kotlinx.js.ReadonlyArray

sealed external interface Value

inline fun  Value(
    vararg value: T?,
): Value = value.unsafeCast>()

inline fun  Value?.toArray(): ReadonlyArray =
    when (this) {
        null -> emptyArray()
        is Array<*> -> unsafeCast>()
        else -> arrayOf(this.unsafeCast())
    }

inline fun  Value?.only(): T? =
    when (this) {
        null -> null
        is Array<*> ->
            if (this.isNotEmpty()) {
                single().unsafeCast()
            } else null

        else -> unsafeCast()
    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy