main.go 325 B

123456789101112131415161718192021222324252627
  1. package objects
  2. import "github.com/d5/tengo/v2"
  3. const src = `
  4. new := func() {
  5. self := {}
  6. self.def = func(name, method){
  7. self[name] = func(...args){
  8. return method(self, args...)
  9. }
  10. }
  11. return self
  12. }
  13. export {
  14. new: new
  15. }
  16. `
  17. func GetModule() tengo.Importable {
  18. return &tengo.SourceModule{
  19. Src: []byte(src),
  20. }
  21. }