ws

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

README

go-workerglobalscope

Go Reference

A wrapper for go in WebAssembly in a Worker context to expose some API (console, fetch) and some Js value (Date, Uint8Array). The console package and the fetch package can be used in main js worker, not only in a Worker.

Warning

  • This module is based on a experimental package without compatibilty, so it can be break in future Realease of Go. We use Go 1.16
  • Not all API and all properties and methods will be wrapper, but you can complete it for your own needs.
  • The goal is to support modern browser that, it suppose to support fetch API...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NegativeOffset    = errors.New("No support for negative offset")
	InvalidSeekWhence = errors.New("Invalid seek whence")
)
View Source
var (
	Uint8Array js.Value = js.Global().Get("Uint8Array")
	Blob       js.Value = js.Global().Get("Blob")
	Object     js.Value = js.Global().Get("Object")
	Array      js.Value = js.Global().Get("Array")
	Date       js.Value = js.Global().Get("Date")
)

Functions

func Await

func Await(promise js.Value) (resolve, reject js.Value)

Resolve the promise.

func AwaitError

func AwaitError(promise js.Value) (resolve js.Value, err error)

AwaitError resolve the promise. If fail the error contain the js object and his string value.

func NewBlob

func NewBlob(mime string, b []byte) js.Value

NewBlob create a new blob with the mime type mime and the blob content is b.

func NewDate

func NewDate(t time.Time) js.Value

NewDate create a js.Value of type Date from t.

func NewUint8Array

func NewUint8Array(b []byte) js.Value

func ReadBody

func ReadBody(body js.Value) (interface {
	io.Reader
	io.ReaderAt
	// io.Seeker
	js.Wrapper
}, error)

ReadBody creates a io.Reader with the Body.arrayBuffer(). The error implement js.JSValue

Body is a mixin for a Blob (File inherit of a Blob) or a fetch response. https://fetch.spec.whatwg.org/#body

Types

This section is empty.

Directories

Path Synopsis
A part of the operation over the console.
A part of the operation over the console.

Jump to

Keyboard shortcuts

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