js

package
v0.0.0-...-47b1c0b Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagBigDecimal    = Tag(internal.TagBigDecimal)
	TagBigInt        = Tag(internal.TagBigInt)
	TagBigFloat      = Tag(internal.TagBigFloat)
	TagSymbol        = Tag(internal.TagSymbol)
	TagString        = Tag(internal.TagString)
	TagObject        = Tag(internal.TagObject)
	TagInt           = Tag(internal.TagInt)
	TagBool          = Tag(internal.TagBool)
	TagNull          = Tag(internal.TagNull)
	TagUndefined     = Tag(internal.TagUndefined)
	TagUninitialized = Tag(internal.TagUninitialized)
	TagCatchOffset   = Tag(internal.TagCatchOffset)
	TagException     = Tag(internal.TagException)
	TagFloat64       = Tag(internal.TagFloat64)
)

Variables

This section is empty.

Functions

func AddIntrinsicConsole

func AddIntrinsicConsole(r realmConfig) error

func AddIntrinsicTimeout

func AddIntrinsicTimeout(r realmConfig) error

func DefinePropertyNoExotic

func DefinePropertyNoExotic(c *propertyConfig) error

func DefinePropertyThrow

func DefinePropertyThrow(c *propertyConfig) error

func EvalOptionBacktraceBarrier

func EvalOptionBacktraceBarrier(c *evalConfig)

func EvalOptionStrict

func EvalOptionStrict(c *evalConfig)

func EvalOptionStrip

func EvalOptionStrip(c *evalConfig)

func NewInternalError

func NewInternalError(format string, v ...interface{}) error

func NewRangeError

func NewRangeError(format string, v ...interface{}) error

func NewReferenceError

func NewReferenceError(format string, v ...interface{}) error

func NewSyntaxError

func NewSyntaxError(format string, v ...interface{}) error

func NewTypeError

func NewTypeError(format string, v ...interface{}) error

Types

type AsyncResult

type AsyncResult struct {
	Value *Value
	Error error
}

type Atom

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

func (*Atom) ToString

func (a *Atom) ToString() (string, error)

func (*Atom) ToStringValue

func (a *Atom) ToStringValue() (*Value, error)

func (*Atom) ToValue

func (a *Atom) ToValue() (*Value, error)

type DefinePropertyOption

type DefinePropertyOption func(*Realm, *propertyConfig) error

func DefinePropertyConfigurable

func DefinePropertyConfigurable(b bool) DefinePropertyOption

func DefinePropertyEnumerable

func DefinePropertyEnumerable(b bool) DefinePropertyOption

func DefinePropertyGetter

func DefinePropertyGetter(getter interface{}) DefinePropertyOption

func DefinePropertySetter

func DefinePropertySetter(setter interface{}) DefinePropertyOption

func DefinePropertyValue

func DefinePropertyValue(v interface{}) DefinePropertyOption

func DefinePropertyWritable

func DefinePropertyWritable(b bool) DefinePropertyOption

type Error

type Error Value

func (*Error) Error

func (e *Error) Error() string

func (*Error) JSValue

func (e *Error) JSValue(r *Realm) (*Value, error)

func (*Error) Stack

func (e *Error) Stack() string

type EvalOption

type EvalOption func(*evalConfig)

type Function

type Function Value

func (*Function) Call

func (f *Function) Call(thisObject *Value, args ...interface{}) (*Value, error)

func (*Function) JSValue

func (f *Function) JSValue(r *Realm) (*Value, error)

type InternalError

type InternalError string

func (InternalError) Error

func (e InternalError) Error() string

type InvalidParameterTypeError

type InvalidParameterTypeError struct {
	Index int
	Type  reflect.Type
}

func (*InvalidParameterTypeError) Error

func (e *InvalidParameterTypeError) Error() string

type InvalidTypeError

type InvalidTypeError struct {
	Type reflect.Type
}

func (*InvalidTypeError) Error

func (e *InvalidTypeError) Error() string

type JSValuer

type JSValuer interface {
	JSValue(r *Realm) (*Value, error)
}

type Literal

type Literal string

func (Literal) JSValue

func (l Literal) JSValue(r *Realm) (*Value, error)

type NotEnoughParametersError

type NotEnoughParametersError struct {
	Required, Actual int
}

func (*NotEnoughParametersError) Error

func (e *NotEnoughParametersError) Error() string

type RangeError

type RangeError string

func (RangeError) Error

func (e RangeError) Error() string

type Realm

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

Realm is a distinct global environment.

See https://github.com/tc39/proposal-realms.

func (*Realm) Convert

func (r *Realm) Convert(v interface{}) (*Value, error)

func (*Realm) Eval

func (r *Realm) Eval(script string, opts ...EvalOption) (*Value, error)

func (*Realm) EvalBinary

func (r *Realm) EvalBinary(buf []byte) (*Value, error)

func (*Realm) EvalFile

func (r *Realm) EvalFile(file string, opts ...EvalOption) (*Value, error)

func (*Realm) EvalModule

func (r *Realm) EvalModule(script string, opts ...EvalOption) (*Value, error)

func (*Realm) EvalModuleFile

func (r *Realm) EvalModuleFile(file string, opts ...EvalOption) (*Value, error)

func (*Realm) GlobalObject

func (r *Realm) GlobalObject() (*Value, error)

func (*Realm) LoadValue

func (r *Realm) LoadValue(buf []byte) (*Value, error)

func (*Realm) NewArrayBuffer

func (r *Realm) NewArrayBuffer(data []byte) (*Value, error)

func (*Realm) NewBoolean

func (r *Realm) NewBoolean(b bool) (*Value, error)

func (*Realm) NewFloat

func (r *Realm) NewFloat(n float64) (*Value, error)

func (*Realm) NewFunction

func (r *Realm) NewFunction(f interface{}) (*Value, error)

func (*Realm) NewInt

func (r *Realm) NewInt(n int) (*Value, error)

func (*Realm) NewObject

func (r *Realm) NewObject() (*Value, error)

func (*Realm) NewObjectProto

func (r *Realm) NewObjectProto(proto *Value) (*Value, error)

func (*Realm) NewObjectWithFinalizer

func (r *Realm) NewObjectWithFinalizer(f func()) (*Value, error)

func (*Realm) NewString

func (r *Realm) NewString(s string) (*Value, error)

func (*Realm) NewStringAtom

func (r *Realm) NewStringAtom(s string) *Atom

func (*Realm) ParseJSON

func (r *Realm) ParseJSON(data string, filename string) (*Value, error)

func (*Realm) SetConstructor

func (r *Realm) SetConstructor(funcObj, proto *Value)

func (*Realm) SetConstructorBit

func (r *Realm) SetConstructorBit(obj *Value, val bool)

type RealmOption

type RealmOption func(r realmConfig) error

func AddIntrinsicConsoleWithLogger

func AddIntrinsicConsoleWithLogger(l *log.Logger) RealmOption

type ReferenceError

type ReferenceError string

func (ReferenceError) Error

func (e ReferenceError) Error() string

type Runtime

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

func NewRuntime

func NewRuntime(defaultRealmOptions ...RealmOption) *Runtime

func (*Runtime) Compile

func (rt *Runtime) Compile(script, filename string, opts ...EvalOption) ([]byte, error)

func (*Runtime) CompileFile

func (rt *Runtime) CompileFile(file string, opts ...EvalOption) ([]byte, error)

func (*Runtime) CompileModule

func (rt *Runtime) CompileModule(script, filename string, opts ...EvalOption) ([]byte, error)

func (*Runtime) CompileModuleFile

func (rt *Runtime) CompileModuleFile(file string, opts ...EvalOption) ([]byte, error)

func (*Runtime) EvalBinaryNodeModule

func (rt *Runtime) EvalBinaryNodeModule(buf []byte) (*Value, error)

func (*Runtime) EvalNodeModule

func (rt *Runtime) EvalNodeModule(script string, opts ...EvalOption) (*Value, error)

func (*Runtime) EvalNodeModuleFile

func (rt *Runtime) EvalNodeModuleFile(file string, opts ...EvalOption) (*Value, error)

func (*Runtime) HasAsyncTasks

func (rt *Runtime) HasAsyncTasks() bool

func (*Runtime) NewRealm

func (rt *Runtime) NewRealm(opts ...RealmOption) (*Realm, error)

func (*Runtime) ParseJSON

func (rt *Runtime) ParseJSON(data string, filename string) (*Value, error)

func (*Runtime) StartEventLoop

func (rt *Runtime) StartEventLoop(ctx context.Context, waitForever bool) error

type SyntaxError

type SyntaxError string

func (SyntaxError) Error

func (e SyntaxError) Error() string

type Tag

type Tag internal.Tag

func (Tag) String

func (t Tag) String() string

type TypeError

type TypeError string

func (TypeError) Error

func (e TypeError) Error() string

type TypedValue

type TypedValue interface {
	FromValue(r *Realm, v *Value) (bool, error)
}

type Value

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

func Must

func Must(v *Value, err error) *Value

func NewBoolean

func NewBoolean(b bool) *Value

func NewFalse

func NewFalse() *Value

func NewNull

func NewNull() *Value

func NewTrue

func NewTrue() *Value

func NewUndefined

func NewUndefined() *Value

func ObjectAssign

func ObjectAssign(dst *Value, src *Value) (*Value, error)

func (*Value) Bytes

func (v *Value) Bytes() []byte

WriteTo writes a pre-compiled script to the writer

func (*Value) Call

func (v *Value) Call(thisObject *Value, args ...interface{}) (*Value, error)

func (*Value) CallAsync

func (v *Value) CallAsync(thisObject *Value, args ...interface{}) <-chan *AsyncResult

func (*Value) CallValues

func (v *Value) CallValues(thisObject *Value, args []*Value) (*Value, error)

func (*Value) CallValuesAsync

func (v *Value) CallValuesAsync(thisObject *Value, args []*Value) <-chan *AsyncResult

func (*Value) Construct

func (v *Value) Construct(args ...interface{}) (*Value, error)

func (*Value) DefineProperty

func (v *Value) DefineProperty(prop string, opts ...DefinePropertyOption) (bool, error)

func (*Value) DefinePropertyAtom

func (v *Value) DefinePropertyAtom(prop *Atom, opts ...DefinePropertyOption) (bool, error)

func (*Value) Get

func (v *Value) Get(property string) (*Value, error)

func (*Value) GetAtom

func (v *Value) GetAtom(atom *Atom) (*Value, error)

func (*Value) Index

func (v *Value) Index(index int) (*Value, error)

func (*Value) Interface

func (v *Value) Interface() interface{}

func (*Value) Invoke

func (v *Value) Invoke(name string, args ...interface{}) (*Value, error)

func (*Value) InvokeAsync

func (v *Value) InvokeAsync(name string, args ...interface{}) <-chan *AsyncResult

func (*Value) InvokeValues

func (v *Value) InvokeValues(name string, args []*Value) (*Value, error)

func (*Value) InvokeValuesAsync

func (v *Value) InvokeValuesAsync(name string, args []*Value) <-chan *AsyncResult

func (*Value) IsArray

func (v *Value) IsArray() bool

func (*Value) IsFloat

func (v *Value) IsFloat() bool

func (*Value) IsFunction

func (v *Value) IsFunction() bool

func (*Value) IsInt

func (v *Value) IsInt() bool

func (*Value) IsNumber

func (v *Value) IsNumber() bool

func (*Value) IsObject

func (v *Value) IsObject() bool

func (*Value) IsString

func (v *Value) IsString() bool

func (*Value) IsSymbol

func (v *Value) IsSymbol() bool

func (*Value) IsTruthy

func (v *Value) IsTruthy() (bool, error)

func (*Value) OwnPropertyNames

func (v *Value) OwnPropertyNames() []*Atom

func (*Value) Set

func (v *Value) Set(prop string, val interface{}) (bool, error)

func (*Value) String

func (v *Value) String() string

func (*Value) Tag

func (v *Value) Tag() Tag

func (*Value) ToBool

func (v *Value) ToBool() bool

func (*Value) ToFloat

func (v *Value) ToFloat() float64

func (*Value) ToInt

func (v *Value) ToInt() int

func (*Value) ToString

func (v *Value) ToString() string

Jump to

Keyboard shortcuts

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