inkwasm

package
v0.0.0-...-049d347 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
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 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

func NewObjectFromSyscall(o js.Value) Object

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 (Object) Bool

func (o Object) Bool() (bool, error)

Bool gets current Object value to bool. It will return error if the current Object isn't TypeBoolean.

func (Object) Bytes

func (o Object) Bytes(buf []byte) ([]byte, error)

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

func (o Object) Call(method string, args ...interface{}) (Object, error)

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

func (o Object) CallVoid(method string, args ...interface{}) error

CallVoid is similar to Call, but doesn't return the resulting Object. Look at Call function for more details.

func (Object) Equal

func (o Object) Equal(v Object) bool

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

func (o Object) Float() (float64, error)

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) GetIndex

func (o Object) GetIndex(index int) Object

GetIndex returns given index of the current Object.

func (Object) GetProperty

func (o Object) GetProperty(property string) Object

GetProperty returns property of the current Object.

func (Object) InstanceOf

func (o Object) InstanceOf(v Object) bool

func (Object) Int

func (o Object) Int() (int, error)

Int is a wrapper from Float It will return error if the current Object isn't TypeNumber or higher than int53.

func (Object) Invoke

func (o Object) Invoke(args ...interface{}) (Object, error)

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

func (o Object) InvokeVoid(args ...interface{}) error

InvokeVoid is similar to Invoke, but doesn't return the resulting Object. Look at Invoke function for more details.

func (Object) Length

func (o Object) Length() uint32

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) MustBytes

func (o Object) MustBytes(buf []byte) []byte

MustBytes is a wrapper to Bytes, but suppress errors.

func (Object) MustString

func (o Object) MustString() string

MustString is a wrapper to String, but suppress errors.

func (Object) New

func (o Object) New(args ...interface{}) (Object, error)

New uses the "new" operator from Javascript with the current object as the constructor and the given arg as arguments.

func (Object) SetProperty

func (o Object) SetProperty(property string, value string)

SetProperty defines the given property of the current Object with the given value.

func (Object) StrictEqual

func (o Object) StrictEqual(v Object) bool

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) String

func (o Object) String() (string, error)

String return the value from the current Object as golang's string.

func (Object) Truthy

func (o Object) Truthy() bool

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

Jump to

Keyboard shortcuts

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