Hey! I've a question. I'm looking for a way to int...
# squarelibraries
g
Hey! I've a question. I'm looking for a way to interact somehow with
js
library from shared kotlin common module for android and iOS targets. As far as i understood i dont need whole
Zipline
for this, it is enough to have
QuickJs
imports. What i'm trying to play with is:
Copy code
private const val libPath = "libs/my_lib.js"
private const val script = "foo(10.1234, 2, false);"

fun testFooJsLib(): String {
    val quickJs = QuickJs.create()
    val result = quickJs.evaluate(script = script, fileName = libPath)
    return result.toString()
}
But i'm getting
app.cash.zipline.QuickJsException: 'foo' is not defined
- so where i need to place my
my_lib.js
file to be able to call functions from it? Thx beforehand! because i haven't found any similiar case in web or here
j
The file name argument doesn’t load that file from the file system, you have to do that yourself
👍 1
The file name argument just tells QuickJS what name to use when printing stack traces
Read the file into a string , call evaluate() to load that string into QuickJS