You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
602 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package jsruntime
  2. import (
  3. "github.com/dop251/goja"
  4. "log"
  5. )
  6. func (jr *JsRuntime) EnableTimeoutFunc() {
  7. jr.runtime.Set("setTimeout", func(call goja.FunctionCall) goja.Value {
  8. if fn, ok := goja.AssertFunction(call.Argument(0)); ok {
  9. //delay := call.Argument(1).ToInteger()
  10. var args []goja.Value
  11. if len(call.Arguments) > 2 {
  12. args = call.Arguments[2:]
  13. }
  14. //
  15. //time.Sleep(time.Duration(delay) * time.Millisecond)
  16. fn(nil, args...)
  17. }
  18. return jr.runtime.ToValue(123124512)
  19. })
  20. jr.runtime.Set("clearTimeout", func(i int64) {
  21. log.Println("clearTimeout暂未支持")
  22. })
  23. }