Documentation
¶
Index ¶
- Variables
- func AssertTypeEquals(jsValue js.Value, jsType js.Type) error
- func AssertTypeOneOf(jsValue js.Value, jsTypes ...js.Type) error
- func BytesToJs(data []byte) js.Value
- func Get(expr string) (js.Value, error)
- func GetBoolean(expr string) (bool, error)
- func GetFloat(expr string) (float64, error)
- func GetFromScope(scope js.Value, expr string) (js.Value, error)
- func GetFunction(expr string) (js.Value, error)
- func GetInt(expr string) (int, error)
- func GetString(expr string) (string, error)
- func GetTruthyBoolean(expr string) (bool, error)
- func Invoke(fn js.Value, args ...any) (js.Value, error)
- func InvokeFunction(expr string, args ...any) (js.Value, error)
- func JsCopyBytes(data js.Value, dst []byte) (int, error)
- func JsToBytes(data js.Value) ([]byte, error)
- func SetGlobalProperties(kv map[string]any)
Constants ¶
This section is empty.
Variables ¶
var TruthyTypes = []js.Type{ js.TypeUndefined, js.TypeNull, js.TypeBoolean, js.TypeNumber, js.TypeString, js.TypeSymbol, js.TypeFunction, js.TypeObject, }
TruthyTypes is a set (slice) of all js.Type which can be treated as a boolean.
Functions ¶
func AssertTypeEquals ¶
AssertTypeEquals returns nil if a given JavaScript value conforms to the given type.
func AssertTypeOneOf ¶
AssertTypeOneOf returns nil if a given JavaScript value conforms to one the given types
func GetBoolean ¶
GetBoolean retrieves a type-checked boolean from the global scope.
func GetFromScope ¶
GetFromScope retrieves an expression from the given scope.
func GetFunction ¶ added in v0.0.2
GetFunction retrieves a type-checked function from the global scope.
func GetTruthyBoolean ¶
GetTruthyBoolean retrieves a type-checked (truthy) boolean from the global scope.
func InvokeFunction ¶
InvokeFunction invokes a type-checked function from the global scope with the given arguments.
func JsCopyBytes ¶ added in v1.0.0
JsCopyBytes loads a Uint8Array or Uint8ClampedArray to a byte slice. It returns the number of bytes copied, which will be the minimum of the lengths of data and dst.
func JsToBytes ¶ added in v1.0.0
JsToBytes converts a JavaScript Uint8Array or Uint8ClampedArray to a Go byte slice.
func SetGlobalProperties ¶ added in v1.0.0
SetGlobalProperties sets propreties on the global object.
Types ¶
This section is empty.