Просмотр исходного кода

internal/jsre: fix built-in inspect function

inspect was broken by ffaf58f0a98 (May 2016!).
Looks like nobody uses this function.
Felix Lange 9 лет назад
Родитель
Сommit
2be3c4b0e3
2 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      internal/jsre/jsre.go
  2. 3 3
      internal/jsre/pretty.go

+ 1 - 1
internal/jsre/jsre.go

@@ -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
 }
 

+ 3 - 3
internal/jsre/pretty.go

@@ -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()
 }