gwasm

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 11 Imported by: 12

README

gwasm

Common utilities I find myself rewriting too often across Go WASM projects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddScript

func AddScript(url, objName string, timeout time.Duration)

AddScript is a helper function for adding a script to HTML document head and verifying it was added correctly given the object name. If no object name is passed the script will not wait

func Debug added in v0.0.2

func Debug(a ...interface{})

Debug prints JSON representation of underlying js.Value if found. Not for use with common Go types.

func DownloadStream

func DownloadStream(filename, contentType string, r io.Reader) error

DownloadStream downloads an io.Reader's contents as a file with the contentType (i.e. "text/csv", "application/json")

func JSColor

func JSColor(c color.Color) string

JSColor converts a Go Color to the javascript string representation

func JSTypedArray

func JSTypedArray(sliceOrArray interface{}) (js.Value, error)

JSTypedArray returns a javascript TypedArray for the corresponding Go type. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

func ValueFromStruct

func ValueFromStruct(Struct interface{}, skipZeroValues bool) js.Value

ValueFromStruct converts a struct with `js` field tags to a javascript Object type with the non-nil fields set to the struct's values. if skipZeroValues is true then fields with a Go zero-value are not set in the javascript resulting object.

Types

type JSValuer

type JSValuer interface {
	JSValue() js.Value
}

Jump to

Keyboard shortcuts

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