internal/jsre: fix built-in inspect function

inspect was broken by ffaf58f0a9 (May 2016!).
Looks like nobody uses this function.
This commit is contained in:
Felix Lange 2016-12-11 01:53:34 +01:00
parent 0ee796632a
commit 2be3c4b0e3
2 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,7 @@ func New(assetPath string, output io.Writer) *JSRE {
}
go re.runEventLoop()
re.Set("loadScript", re.loadScript)
re.Set("inspect", prettyPrintJS)
re.Set("inspect", re.prettyPrintJS)
return re
}

View File

@ -73,10 +73,10 @@ func jsErrorString(err error) string {
return err.Error()
}
func prettyPrintJS(call otto.FunctionCall, w io.Writer) otto.Value {
func (re *JSRE) prettyPrintJS(call otto.FunctionCall) otto.Value {
for _, v := range call.ArgumentList {
prettyPrint(call.Otto, v, w)
fmt.Fprintln(w)
prettyPrint(call.Otto, v, re.output)
fmt.Fprintln(re.output)
}
return otto.UndefinedValue()
}