suspendFunction
suspend fun suspendFunction(target: JsObject, name: String, arity: Int = 0, scope: CoroutineScope, body: suspend (List<JsValue>) -> Any?): JsFunction(source)
Binds a host function that suspends. The script sees a normal function returning a promise; body runs on scope and settles it. A body that throws, or is cancelled with scope before or while it runs, rejects the promise with the failure's message.
body runs off the engine's thread, so its arguments follow the rule above: scalars can be read as they are, and an object or a function argument is read inside onEngine.