Documentation ¶
Index ¶
- Variables
- type Object
- func (o Object) Bool() (bool, error)
- func (o Object) Bytes(buf []byte) ([]byte, error)
- func (o Object) Call(method string, args ...interface{}) (Object, error)
- func (o Object) CallVoid(method string, args ...interface{}) error
- func (o Object) Equal(v Object) bool
- func (o Object) Float() (float64, error)
- func (o Object) Free()
- func (o Object) GetIndex(index int) Object
- func (o Object) GetProperty(property string) Object
- func (o Object) InstanceOf(v Object) bool
- func (o Object) Int() (int, error)
- func (o Object) Invoke(args ...interface{}) (Object, error)
- func (o Object) InvokeVoid(args ...interface{}) error
- func (o Object) Length() uint32
- func (o Object) MustBytes(buf []byte) []byte
- func (o Object) MustString() string
- func (o Object) New(args ...interface{}) (Object, error)
- func (o Object) SetProperty(property string, value string)
- func (o Object) StrictEqual(v Object) bool
- func (o Object) String() (string, error)
- func (o Object) Truthy() bool
- type ObjectType
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidType = errors.New("invalid type") ErrExecutionJS = errors.New("error while executing/calling Javascript, see console log for details") )
Functions ¶
This section is empty.
Types ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents one Javascript Object
func Global ¶
func Global() Object
Global returns an Object of globalThis https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/globalThis
func NewObject ¶
func NewObject() Object
NewObject creates a new Javascript Object.
The resulting Object must be released using Free, when no longer in use.
func NewObjectFromSyscall ¶
NewObjectFromSyscall creates a new Object using the given js.Value. It will copy the information and calls Javascript functions.
You must avoid calling that function. You also must release the resulting Object using Free, when no longer in use.
It's useful for js.FuncOf, since Golang doesn't have option to export function directly.
func Null ¶
func Null() Object
Null returns an Object of null https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/null
func Undefined ¶
func Undefined() Object
Undefined returns an Object of undefined https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/undefined
func (Object) Bool ¶
Bool gets current Object value to bool. It will return error if the current Object isn't TypeBoolean.
func (Object) Bytes ¶
Bytes return the value from the current Object as byte-slice.
If buf is nil, a new byte-slice will be created and used instead.
func (Object) Call ¶
Call calls the method from the current Object, using args as arguments for the method.
The resulting Object must be released using Free, when no longer in use.
func (Object) CallVoid ¶
CallVoid is similar to Call, but doesn't return the resulting Object. Look at Call function for more details.
func (Object) Equal ¶
Equal returns if o Object is equal (==) to v.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality.
func (Object) Float ¶
Float gets current Object value to float64. It will return error if the current Object isn't TypeNumber.
func (Object) Free ¶
func (o Object) Free()
Free deletes the reference from the array on Javascript's side.
func (Object) GetProperty ¶
GetProperty returns property of the current Object.
func (Object) InstanceOf ¶
func (Object) Int ¶
Int is a wrapper from Float It will return error if the current Object isn't TypeNumber or higher than int53.
func (Object) Invoke ¶
Invoke invokes the current Object, calling itself with the provided args as arguments of the function.
The Object must be a Javascript-Function, or be callable. The resulting Object must be released using Free, when no longer in use.
func (Object) InvokeVoid ¶
InvokeVoid is similar to Invoke, but doesn't return the resulting Object. Look at Invoke function for more details.
func (Object) Length ¶
Length returns the length of the current object, when the object is string or array.
It uses uint32, use GetProperty("length") for larger results.
func (Object) MustString ¶
MustString is a wrapper to String, but suppress errors.
func (Object) New ¶
New uses the "new" operator from Javascript with the current object as the constructor and the given arg as arguments.
func (Object) SetProperty ¶
SetProperty defines the given property of the current Object with the given value.
func (Object) StrictEqual ¶
StrictEqual returns if o Object is strict-equal (===) to v.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality.
func (Object) Truthy ¶
Truthy returns the JavaScript "truthiness" of the value v. In JavaScript, false, 0, "", null, undefined, and NaN are "falsy", and everything else is "truthy".
See https://developer.mozilla.org/en-US/docs/Glossary/Truthy.
type ObjectType ¶
type ObjectType uint8
const ( TypeUndefined ObjectType = iota TypeNull TypeBoolean TypeNumber TypeBigInt TypeString TypeSymbol TypeFunction TypeObject )
func (ObjectType) String ¶
func (o ObjectType) String() string