I need to generate uuid in Kotlin/JS and looking to call uuid.v4() from Kotlin/JS. I have gone through the documentation - https://kotlinlang.org/docs/using-packages-from-npm.html and https://kotlinlang.org/docs/js-modules.html but somehow cannot figure out how to invoke.
What I did is this -
val jsMain by getting {
dependencies {
implementation(npm("uuid", "9.0.0"))
}
}
@JsModule("uuid")
@JsNonModule
external fun v4(options: Any?, buf: Any?, offset: Any?): String
v4(null, null, null)
doesn't works.I get this error in console -
Uncaught ReferenceError: v4 is not defined
This is how it will work -
val jsMain by getting {
dependencies {
implementation(npm("uuid", "9.0.0"))
}
}
@JsModule("uuid")
@JsNonModule
external val uuid: dynamic
uuid.v4()