console.go 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package otto
  2. import (
  3. "fmt"
  4. "os"
  5. "strings"
  6. )
  7. func formatForConsole(argumentList []Value) string {
  8. output := []string{}
  9. for _, argument := range argumentList {
  10. output = append(output, fmt.Sprintf("%v", argument))
  11. }
  12. return strings.Join(output, " ")
  13. }
  14. func builtinConsole_log(call FunctionCall) Value {
  15. fmt.Fprintln(os.Stdout, formatForConsole(call.ArgumentList))
  16. return Value{}
  17. }
  18. func builtinConsole_error(call FunctionCall) Value {
  19. fmt.Fprintln(os.Stdout, formatForConsole(call.ArgumentList))
  20. return Value{}
  21. }
  22. // Nothing happens.
  23. func builtinConsole_dir(call FunctionCall) Value {
  24. return Value{}
  25. }
  26. func builtinConsole_time(call FunctionCall) Value {
  27. return Value{}
  28. }
  29. func builtinConsole_timeEnd(call FunctionCall) Value {
  30. return Value{}
  31. }
  32. func builtinConsole_trace(call FunctionCall) Value {
  33. return Value{}
  34. }
  35. func builtinConsole_assert(call FunctionCall) Value {
  36. return Value{}
  37. }
  38. func (runtime *_runtime) newConsole() *_object {
  39. return newConsoleObject(runtime)
  40. }