jsutil

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RuntimeContext      = js.Global().Get("context")
	Binding             = js.Global().Get("context").Get("binding")
	ObjectClass         = js.Global().Get("Object")
	PromiseClass        = js.Global().Get("Promise")
	RequestClass        = js.Global().Get("Request")
	ResponseClass       = js.Global().Get("Response")
	HeadersClass        = js.Global().Get("Headers")
	ArrayClass          = js.Global().Get("Array")
	Uint8ArrayClass     = js.Global().Get("Uint8Array")
	ErrorClass          = js.Global().Get("Error")
	ReadableStreamClass = js.Global().Get("ReadableStream")
	DateClass           = js.Global().Get("Date")
	Null                = js.ValueOf(nil)
)

Functions

func ArrayFrom

func ArrayFrom(v js.Value) js.Value

ArrayFrom calls Array.from to given argument and returns result Array.

func AwaitPromise

func AwaitPromise(promiseVal js.Value) (js.Value, error)

func ConvertReaderToReadableStream

func ConvertReaderToReadableStream(reader io.ReadCloser) js.Value

ConvertReaderToReadableStream converts io.ReadCloser to ReadableStream.

func ConvertStreamReaderToReader

func ConvertStreamReaderToReader(sr js.Value) io.Reader

ConvertStreamReaderToReader converts ReadableStreamDefaultReader to io.Reader.

func DateToTime

func DateToTime(v js.Value) (time.Time, error)

DateToTime converts JavaScript side's Data object into time.Time.

func MaybeDate

func MaybeDate(v js.Value) (time.Time, error)

MaybeDate returns time.Time value of given JavaScript Date value or returns nil if the value is undefined.

func MaybeString

func MaybeString(v js.Value) string

MaybeString returns string value of given JavaScript value or returns nil if the value is undefined.

func NewObject

func NewObject() js.Value

func NewPromise

func NewPromise(fn js.Func) js.Value

func NewUint8Array

func NewUint8Array(size int) js.Value

func StrRecordToMap

func StrRecordToMap(v js.Value) map[string]string

StrRecordToMap converts JavaScript side's Record<string, string> into map[string]string.

func TimeToDate

func TimeToDate(t time.Time) js.Value

TimeToDate converts Go side's time.Time into Date object.

func TryCatch

func TryCatch(fn js.Func) (js.Value, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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