1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/pkg/stdlib/utils/wait.go
Tim Voronov 6933798419
Bugfix/#295 arithmetic operators (#298)
* Some work

* Updated Add operator

* Updated Subtract operator

* Updated Subtract operator tests

* Added tests for multiplication

* Added division

* Updated the rest of operators
2019-05-19 12:12:11 -04:00

26 lines
559 B
Go

package utils
import (
"context"
"time"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
// Wait pauses the execution for a given period.
// @param timeout (Float|Int) - Number value which indicates for how long to stop an execution.
func Wait(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 1, 1)
if err != nil {
return values.None, nil
}
arg := values.ToInt(args[0])
time.Sleep(time.Millisecond * time.Duration(arg))
return values.None, nil
}