AsyncKiteJs
An engine that lives on one thread, so suspending code can use it from anywhere.
The engine underneath is single-threaded, as JavaScript is, and the thread that opened it holds it. Every call here hops onto that thread, one at a time, so two callers never overlap.
The values that come back are the engine's own. A number, a string, a boolean, a BigInt, null or undefined is a copy and can be read anywhere. An object, an array or a function still belongs to the engine, so read it inside onEngine; touched from another thread it throws JsEngineError rather than running script there.
val js = asyncKiteJs(Rhino)
js.use { println(js.evaluate("1 + 1").asDouble()) }
js.close()Functions
Waits for value as await does in a script. A promise comes back as what it fulfils with, and a rejection as the JsError it carries. Any other thenable is resolved the way a promise resolves it, so a thenable that answers with a promise comes back as that promise's value. A value that is not thenable comes straight back.
Runs source and, if it answers a promise, waits for that promise to settle.