init.go 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package js
  2. import (
  3. "github.com/evilsocket/islazy/log"
  4. "github.com/evilsocket/islazy/plugin"
  5. "github.com/robertkrimen/otto"
  6. )
  7. var NullValue = otto.Value{}
  8. func ReportError(format string, args ...interface{}) otto.Value {
  9. log.Error(format, args...)
  10. return NullValue
  11. }
  12. func init() {
  13. // TODO: refactor this in packages
  14. plugin.Defines["readDir"] = readDir
  15. plugin.Defines["readFile"] = readFile
  16. plugin.Defines["writeFile"] = writeFile
  17. plugin.Defines["log"] = flog
  18. plugin.Defines["log_debug"] = log_debug
  19. plugin.Defines["log_info"] = log_info
  20. plugin.Defines["log_warn"] = log_warn
  21. plugin.Defines["log_error"] = log_error
  22. plugin.Defines["log_fatal"] = log_fatal
  23. plugin.Defines["btoa"] = btoa
  24. plugin.Defines["atob"] = atob
  25. plugin.Defines["gzipCompress"] = gzipCompress
  26. plugin.Defines["gzipDecompress"] = gzipDecompress
  27. plugin.Defines["httpRequest"] = httpRequest
  28. plugin.Defines["http"] = httpPackage{}
  29. plugin.Defines["random"] = randomPackage{}
  30. }