api

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

View Source
const LOG_DEPTH = 4 // skip through reflection to goja code

Variables

View Source
var Variables = commonjs.NewThreadSafeObject()

Functions

func CreateARDExtension

func CreateARDExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func CreateConsoleExtension

func CreateConsoleExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func CreateEarlyBindExtension

func CreateEarlyBindExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func CreateEnvExtension

func CreateEnvExtension(arguments map[string]string) commonjs.CreateExtensionFunc

func CreateLateBindExtension

func CreateLateBindExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func CreateOSExtension

func CreateOSExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

func CreateTranscribeExtension

func CreateTranscribeExtension(stdout io.Writer, stderr io.Writer) commonjs.CreateExtensionFunc

func CreateUtilExtension

func CreateUtilExtension(jsContext *commonjs.Context) any

(commonjs.CreateExtensionFunc signature)

Types

type ARD

type ARD struct{}

func (ARD) Decode

func (self ARD) Decode(code []byte, format string, all bool) (ard.Value, error)

func (ARD) ValidateFormat

func (self ARD) ValidateFormat(code []byte, format string) error

type Console

type Console struct {
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole(jsContext *commonjs.Context) *Console

func (*Console) Debug

func (self *Console) Debug(arguments ...any)

func (*Console) Error

func (self *Console) Error(arguments ...any)

func (*Console) Info

func (self *Console) Info(arguments ...any)

func (*Console) Log

func (self *Console) Log(arguments ...any)

func (*Console) Trace

func (self *Console) Trace(arguments ...any)

func (*Console) Warn

func (self *Console) Warn(arguments ...any)

type DefaultExtensions

type DefaultExtensions struct {
	LateBind  bool
	Arguments map[string]string
	Stdout    io.Writer
	Stderr    io.Writer
}

func (DefaultExtensions) Create

func (self DefaultExtensions) Create() []commonjs.Extension

type Env

type Env struct {
	Context   *commonjs.Context
	Variables *goja.Object
	Arguments map[string]string
	Log       commonlog.Logger
}

func NewEnv

func NewEnv(jsContext *commonjs.Context, arguments map[string]string) *Env

func (*Env) LoadBytes

func (self *Env) LoadBytes(id string, timeoutSeconds float64) ([]byte, error)

func (*Env) LoadString

func (self *Env) LoadString(id string, timeoutSeconds float64) (string, error)

func (*Env) WriteFrom

func (self *Env) WriteFrom(writer io.Writer, id string, timeoutSeconds float64) error

type OS

type OS struct {
	Stdout io.Writer
	Stderr io.Writer
	// contains filtered or unexported fields
}

func NewOS

func NewOS(urlContext *exturl.Context) OS

func (OS) Download

func (self OS) Download(sourceUrl string, targetPath string, timeoutSeconds float64) error

func (OS) Exec

func (self OS) Exec(name string, arguments ...string) (string, error)

func (OS) JoinFilePath

func (self OS) JoinFilePath(elements ...string) string

func (OS) TemporaryDirectory

func (self OS) TemporaryDirectory(pattern string, directory string) (string, error)

func (OS) TemporaryFile

func (self OS) TemporaryFile(pattern string, directory string) (string, error)

type Transcribe

type Transcribe struct {
	Stdout io.Writer
	Stderr io.Writer
}

func NewTranscribe

func NewTranscribe(stdout io.Writer, stderr io.Writer) *Transcribe

func (Transcribe) Atob

func (self Transcribe) Atob(b64 string) ([]byte, error)

Decode base64 to bytes

func (Transcribe) Eprint

func (self Transcribe) Eprint(value any, format string, indent string) error

func (Transcribe) NewXmlDocument

func (self Transcribe) NewXmlDocument() *etree.Document

func (Transcribe) Print

func (self Transcribe) Print(value any, format string, indent string) error

Encodes and prints the value to stdout. Supported formats are "yaml", "json", "xjson", "xml", "cbor", "messagepack", and "go". The "cbor" and "messsagepack" formats will be encoded in base64 and will ignore the indent argument.

func (Transcribe) Stringify

func (self Transcribe) Stringify(value any, format string, indent string) (string, error)

Encodes the value into a string.Supported formats are "yaml", "json", "xjson", "xml", "cbor", "messagepack", and "go". The "cbor" and "messsagepack" formats will be encoded in base64 and will ignore the indent argument.

func (Transcribe) Write

func (self Transcribe) Write(writer io.Writer, value any, format string, indent string) error

Encodes and writes the value. Supported formats are "yaml", "json", "xjson", "xml", "cbor", "messagepack", and "go". The "cbor" and "messsagepack" formats will ignore the indent argument.

func (Transcribe) WriteText added in v0.2.1

func (self Transcribe) WriteText(writer io.Writer, value any, format string, indent string) error

Encodes and writes the value. Supported formats are "yaml", "json", "xjson", "xml", "cbor", "messagepack", and "go". The "cbor" and "messsagepack" formats will be encoded in base64 and will ignore the indent argument.

type Util

type Util struct {
	// contains filtered or unexported fields
}

func NewUtil

func NewUtil(log commonlog.Logger) *Util

func (*Util) Btoa

func (self *Util) Btoa(bytes []byte) string

Encode bytes as base64

func (*Util) BytesToString

func (self *Util) BytesToString(bytes []byte) string

Another way to achieve this in JavaScript: String.fromCharCode.apply(null, bytes)

func (*Util) DeepCopy

func (self *Util) DeepCopy(value ard.Value) ard.Value

func (*Util) DeepEquals

func (self *Util) DeepEquals(a ard.Value, b ard.Value) bool

func (*Util) EscapeHtml

func (self *Util) EscapeHtml(text string) string

func (*Util) Fail

func (self *Util) Fail(message string)

func (*Util) Failf

func (self *Util) Failf(format string, args ...any)

func (*Util) Go

func (self *Util) Go(value goja.Value, this goja.Value, arguments []goja.Value) error

Goroutine

func (*Util) Hash

func (self *Util) Hash(value ard.Value) (uint64, error)

func (*Util) IsType

func (self *Util) IsType(value ard.Value, typeName string) (bool, error)

func (*Util) Mutex

func (self *Util) Mutex() util.RWLocker

func (*Util) Now

func (self *Util) Now() time.Time

func (*Util) NowString

func (self *Util) NowString() string

func (*Util) Once

func (self *Util) Once(name string, value goja.Value, this goja.Value, arguments []goja.Value) error

func (*Util) Sprintf

func (self *Util) Sprintf(format string, args ...any) string

func (*Util) StringToBytes

func (self *Util) StringToBytes(string_ string) []byte

func (*Util) UnescapeHtml

func (self *Util) UnescapeHtml(text string) string

func (*Util) Url

func (self *Util) Url(config ard.StringMap) (string, error)

Construct a URL via its parts. Supports parts:

  • "scheme": as string
  • "username": as string
  • "password": as string
  • "host": as string
  • "port": as unsigned integer
  • "path": as string
  • "query": map of strings to either a list of multiple values or or a single value as string
  • "fragment": as string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL