mirror of https://github.com/stashapp/stash.git
23 lines
370 B
Go
23 lines
370 B
Go
|
package js
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/robertkrimen/otto"
|
||
|
)
|
||
|
|
||
|
func sleepFunc(call otto.FunctionCall) otto.Value {
|
||
|
arg := call.Argument(0)
|
||
|
ms, _ := arg.ToInteger()
|
||
|
|
||
|
time.Sleep(time.Millisecond * time.Duration(ms))
|
||
|
return otto.UndefinedValue()
|
||
|
}
|
||
|
|
||
|
func AddUtilAPI(vm *otto.Otto) {
|
||
|
util, _ := vm.Object("({})")
|
||
|
util.Set("Sleep", sleepFunc)
|
||
|
|
||
|
vm.Set("util", util)
|
||
|
}
|