gojs

package module
v0.0.0-...-5a8e06f Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 14 Imported by: 0

README

gojs

goja's extended support

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

func ConvertFloat

func ConvertFloat[to float32 | float64](value any) (ret to, e error)

func ConvertInt

func ConvertInt[to int8 | int16 | int32 | int64](value any) (ret to, e error)

func ConvertUint

func ConvertUint[to uint8 | uint16 | uint32 | uint64](value any) (ret to, e error)

func StringToBytes

func StringToBytes(s string) []byte

Types

type Loop

type Loop interface {
	// Enable an asynchronous event
	Go(ctx context.Context, job func(worker Worker)) error
	// Run the event loop until all events complete
	Run(ctx context.Context) (e error)
}

type Number

type Number[T uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64] struct {
	// contains filtered or unexported fields
}

func MakeInt16

func MakeInt16(v int16) Number[int16]

func MakeInt32

func MakeInt32(v int32) Number[int32]

func MakeInt64

func MakeInt64(v int64) Number[int64]

func MakeInt8

func MakeInt8(v int8) Number[int8]

func MakeUint16

func MakeUint16(v uint16) Number[uint16]

func MakeUint32

func MakeUint32(v uint32) Number[uint32]

func MakeUint64

func MakeUint64(v uint64) Number[uint64]

func MakeUint8

func MakeUint8(v uint8) Number[uint8]

func (Number[T]) Add

func (v Number[T]) Add(vals ...any) (ret Number[T], e error)

func (Number[T]) And

func (v Number[T]) And(vals ...any) (ret Number[T], e error)

func (Number[T]) Cmp

func (v Number[T]) Cmp(value any) (int, error)

func (Number[T]) Div

func (v Number[T]) Div(vals ...any) (ret Number[T], e error)

func (Number[T]) DivMod

func (v Number[T]) DivMod(value any) (t0, t1 Number[T], e error)

func (Number[T]) Mod

func (v Number[T]) Mod(vals ...any) (ret Number[T], e error)

func (Number[T]) Mul

func (v Number[T]) Mul(vals ...any) (ret Number[T], e error)

func (Number[T]) Neg

func (v Number[T]) Neg() (ret Number[T])

func (Number[T]) Not

func (v Number[T]) Not() (ret Number[T])

func (Number[T]) Or

func (v Number[T]) Or(vals ...any) (ret Number[T], e error)

func (Number[T]) String

func (v Number[T]) String() string

func (Number[T]) Sub

func (v Number[T]) Sub(vals ...any) (ret Number[T], e error)

func (Number[T]) ToInt16

func (v Number[T]) ToInt16() Number[int16]

func (Number[T]) ToInt32

func (v Number[T]) ToInt32() Number[int32]

func (Number[T]) ToInt64

func (v Number[T]) ToInt64() Number[int64]

func (Number[T]) ToInt8

func (v Number[T]) ToInt8() Number[int8]

func (Number[T]) ToNumber

func (v Number[T]) ToNumber() T

func (Number[T]) ToUint16

func (v Number[T]) ToUint16() Number[uint16]

func (Number[T]) ToUint32

func (v Number[T]) ToUint32() Number[uint32]

func (Number[T]) ToUint64

func (v Number[T]) ToUint64() Number[uint64]

func (Number[T]) ToUint8

func (v Number[T]) ToUint8() Number[uint8]

func (Number[T]) Xor

func (v Number[T]) Xor(vals ...any) (ret Number[T], e error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithConsole

func WithConsole(console bool) Option

func WithContext

func WithContext(ctx context.Context) Option

func WithLoop

func WithLoop(loop Loop) Option

func WithRegistry

func WithRegistry(registry *require.Registry) Option

func WithTimer

func WithTimer(timer bool) Option

type Runtime

type Runtime struct {
	*goja.Runtime
	// contains filtered or unexported fields
}

func New

func New(opt ...Option) *Runtime

func (*Runtime) Cancel

func (r *Runtime) Cancel()

func (*Runtime) GetLoop

func (r *Runtime) GetLoop() Loop

func (*Runtime) GetRegistry

func (r *Runtime) GetRegistry() *require.Registry

func (*Runtime) Go

func (r *Runtime) Go(job func(worker Worker)) error

func (*Runtime) RunLoop

func (r *Runtime) RunLoop() error

func (*Runtime) RunScript

func (r *Runtime) RunScript(name string, src interface{}) (v goja.Value, e error)

type SimpleLoop

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

func NewSimpleLoop

func NewSimpleLoop() *SimpleLoop

func (*SimpleLoop) Go

func (s *SimpleLoop) Go(ctx context.Context, job func(worker Worker)) error

func (*SimpleLoop) Run

func (s *SimpleLoop) Run(ctx context.Context) (e error)

type Worker

type Worker interface {
	// The submission event is completed.
	// If the event system has been destroyed or repeated submission will return an error,
	// you should consider releasing the resource at this time (no other callback function will get the resource and release it)
	Submit(f func()) error
	// Call back data to the event system, but the event has not yet completed
	Next(f func()) error
}

Jump to

Keyboard shortcuts

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