Expose quickjs resource limit and interrupt functionality
Hi!
QuickJS has built-in support for limiting the resource use of its runtimes, discussed on page 13 of the [documentation pdf](https://bellard.org/quickjs/quickjs.pdf) (see bottom).
It would be great if the configuration of these resource limits could be exposed in this package.
In particular, `JS_SetInterruptHandler` allows setting a callback to be called regularly by the JS engine and can allow implementing Ctrl-C functionality a JS REPL, and time-based execution limits for either a VM instance or individual calls to `Eval`.
The related CGo-based package [quickjs-go](https://github.com/buke/quickjs-go) exposes this functionality through an API that allows configuration at construction time, and also supports user-provided execution handlers with `rt.SetInterruptHandler`:
```go
rt := quickjs.NewRuntime(
// Specified in seconds; would be nice if it were a time.Duration,
// or left to the user to implement via SetInterruptHandler
quickjs.WithExecuteTimeout(30),
quickjs.WithMemoryLimit(128*1024),
quickjs.WithGCThreshold(256*1024),
quickjs.WithMaxStackSize(65534),
quickjs.WithCanBlock(true),
)
// This will overwrite the execution timeout with a custom function
rt.SetInterruptHandler(func() int {
// Returning a nonzero value will interrupt execution
return 0
})
```
If it's possible, it would be extremely nice to have this functionality exposed as part of the Go API of this package.
Thank you!
issue