28 lines
473 B
Go
28 lines
473 B
Go
package builtin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/dop251/goja"
|
|
)
|
|
|
|
type Builtin struct {
|
|
Name string
|
|
Function func(*goja.Runtime) func(goja.FunctionCall) goja.Value
|
|
Definition string
|
|
Types []string
|
|
ParamTypes map[string]bool
|
|
}
|
|
|
|
func (b *Builtin) HasParamType(typeName string) bool {
|
|
return b.ParamTypes[typeName]
|
|
}
|
|
|
|
type EmptyArgs struct{}
|
|
|
|
type Args interface {
|
|
Validate() error
|
|
}
|
|
|
|
type Func[T Args, R any] func(ctx context.Context, args T) (R, error)
|