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

main.kotlinext.js.Helpers.kt Maven / Gradle / Ivy

@file:Suppress("NOTHING_TO_INLINE")

package kotlinext.js

inline fun  jso(): T =
    js("({})")

inline fun  jso(builder: T.() -> Unit): T =
    jso().apply(builder)

inline fun js(builder: dynamic.() -> Unit): dynamic = jso(builder)

fun  clone(obj: T) = Object.assign(jso(), obj)

inline fun  assign(obj: T, builder: T.() -> Unit) = clone(obj).apply(builder)

fun toPlainObjectStripNull(obj: Any) = js {
    for (key in Object.keys(obj)) {
        val value = obj.asDynamic()[key]
        if (value != null) this[key] = value
    }
}

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete
external fun delete(p: dynamic): Boolean = definedExternally




© 2015 - 2025 Weber Informatics LLC | Privacy Policy