good morning!!!!

Skip to content
Snippets Groups Projects
Commit 49703bea authored by Felix Lange's avatar Felix Lange
Browse files

jsre: bind the pretty printer to "inspect" in JS

parent 5c5c3930
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ func New(assetPath string) *JSRE {
re.loopWg.Add(1)
go re.runEventLoop()
re.Set("loadScript", re.loadScript)
re.Set("inspect", prettyPrintJS)
return re
}
......
......@@ -54,6 +54,14 @@ func prettyPrint(vm *otto.Otto, value otto.Value) {
ppctx{vm}.printValue(value, 0)
}
func prettyPrintJS(call otto.FunctionCall) otto.Value {
for _, v := range call.ArgumentList {
prettyPrint(call.Otto, v)
fmt.Println()
}
return otto.UndefinedValue()
}
type ppctx struct{ vm *otto.Otto }
func (ctx ppctx) indent(level int) string {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment