This commit is contained in:
2026-01-28 21:59:04 -05:00
parent dcd516d970
commit ffcb6f658b
10 changed files with 60 additions and 134 deletions

View File

@@ -41,17 +41,16 @@ func New(ctx context.Context, opts ...RuntimeOption) (*Runtime, error) {
}
func (r *Runtime) populateGlobals() error {
// Register Custom Functions
for name, fn := range functions.GetRegisteredFunctions() {
// Register Main Function
if fn.IsAsync() {
r.ctx.SetAsyncFunc(name, func(this *qjs.This) {
qjsVal, err := callFunc(this, fn)
if err != nil {
this.Promise().Reject(this.Context().NewError(err))
_ = this.Promise().Reject(this.Context().NewError(err))
return
}
this.Promise().Resolve(qjsVal)
_ = this.Promise().Resolve(qjsVal)
})
} else {
r.ctx.SetFunc(name, func(this *qjs.This) (*qjs.Value, error) {