Documentation ¶
Index ¶
- func Main(def exec.ModuleDefinition)
- func MainErr(def exec.ModuleDefinition) error
- func Run(name string, def exec.ModuleDefinition, options *Options) error
- type ExitError
- type Function
- type Object
- type Options
- type Type
- type Value
- func (v Value) Array() ([]Value, bool)
- func (v Value) Bool() bool
- func (v Value) Call(method string, args []Value) (Value, error)
- func (v Value) Delete(property string)
- func (v Value) Equal(w Value) bool
- func (v Value) Float() float64
- func (v Value) Function() (Function, bool)
- func (v Value) Get(property string) Value
- func (v Value) Index(i int) Value
- func (v Value) Int() int
- func (v Value) Invoke(args []Value) (Value, error)
- func (v Value) IsInstance(class Value) bool
- func (v Value) IsNaN() bool
- func (v Value) IsNull() bool
- func (v Value) IsUndefined() bool
- func (v Value) Length() int
- func (v Value) New(args []Value) (Value, error)
- func (v Value) Object() (Object, bool)
- func (v Value) Set(property string, value Value)
- func (v Value) SetIndex(i int, value Value)
- func (v Value) String() string
- func (v Value) Truthy() bool
- func (v Value) Type() Type
- func (v Value) Uint8Array() ([]byte, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
func Main(def exec.ModuleDefinition)
func MainErr ¶
func MainErr(def exec.ModuleDefinition) error
Types ¶
type Function ¶
type Function interface { Object Invoke(args []Value) (Value, error) New(args []Value) (Value, error) }
var ArrayClass Function = functionObject(newArray)
var ErrorClass Function = functionObject(newError)
var FunctionClass Function = functionObject(newFunction)
var ObjectClass Function = objectClass(0)
var StringClass Function = functionObject(newString)
var Uint8ArrayClass Function = functionObject(newUint8Array)
type Object ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func ValueOf ¶
func ValueOf(x interface{}) Value
ValueOf returns x as a JavaScript value:
| Go | JavaScript | | ---------------------- | ---------------------- | | js.Value | [its value] | | js.Func | function | | nil | null | | bool | boolean | | integers and floats | number | | string | string | | []interface{} | new array | | map[string]interface{} | new object |
Panics if x is not one of the expected types.
func (Value) Equal ¶
Equal reports whether v and w are equal according to JavaScript's === operator.
func (Value) Float ¶
Float returns the value v as a float64. It panics if v is not a JavaScript number.
func (Value) Int ¶
Int returns the value v truncated to an int. It panics if v is not a JavaScript number.
func (Value) IsInstance ¶
func (Value) IsUndefined ¶
IsUndefined reports whether v is the JavaScript value "undefined".
func (Value) String ¶
String returns the value v as a string. String is a special case because of Go's String method convention. Unlike the other getters, it does not panic if v's Type is not TypeString. Instead, it returns a string of the form "<T>" or "<T: V>" where T is v's type and V is a string representation of v's value.
func (Value) 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.
func (Value) Type ¶
Type returns the JavaScript type of the value v. It is similar to JavaScript's typeof operator, except that it returns TypeNull instead of TypeObject for null.