mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Replace javascript module otto with goja (#4631)
* Move plugin javascript to own package with goja * Use javascript package in scraper Remove otto
This commit is contained in:
25
pkg/javascript/util.go
Normal file
25
pkg/javascript/util.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package javascript
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Util struct{}
|
||||
|
||||
func (u *Util) sleepFunc(ms int64) {
|
||||
time.Sleep(time.Millisecond * time.Duration(ms))
|
||||
}
|
||||
|
||||
func (u *Util) AddToVM(globalName string, vm *VM) error {
|
||||
util := vm.NewObject()
|
||||
if err := util.Set("Sleep", u.sleepFunc); err != nil {
|
||||
return fmt.Errorf("unable to set sleep func: %w", err)
|
||||
}
|
||||
|
||||
if err := vm.Set(globalName, util); err != nil {
|
||||
return fmt.Errorf("unable to set util: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user