import "github.com/gopherjs/gopherjs/js"
Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax.
Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed:
| Go type | JavaScript type | Conversions back to interface{} | | --------------------- | --------------------- | ------------------------------- | | bool | Boolean | bool | | integers and floats | Number | float64 | | string | String | string | | []int8 | Int8Array | []int8 | | []int16 | Int16Array | []int16 | | []int32, []int | Int32Array | []int | | []uint8 | Uint8Array | []uint8 | | []uint16 | Uint16Array | []uint16 | | []uint32, []uint | Uint32Array | []uint | | []float32 | Float32Array | []float32 | | []float64 | Float64Array | []float64 | | all other slices | Array | []interface{} | | arrays | see slice type | see slice type | | functions | Function | func(...interface{}) *js.Object | | time.Time | Date | time.Time | | - | instanceof Node | *js.Object | | maps, structs | instanceof Object | map[string]interface{} |
Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa.
func Debugger()
Debugger gets compiled to JavaScript's "debugger;" statement.
Keys returns the keys of the given JavaScript object.
Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object.
Error returns the message of the encapsulated JavaScript error object.
Stack returns the stack property of the encapsulated JavaScript error object.
M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion).
type Object struct {
// contains filtered or unexported fields
}
Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key.
Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js).
Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'.
Undefined gives the JavaScript value "undefined".
InternalObject returns the internal JavaScript object that represents i. Not intended for public use.
MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords.
MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript.
NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice.
Bool returns the object converted to bool according to JavaScript type conversions.
Call calls the object's method with the given name.
Delete removes the object's property with the given key.
Float returns the object converted to float64 according to JavaScript type conversions (parseFloat).
Get returns the object's property with the given key.
Index returns the i'th element of an array.
Int returns the object converted to int according to JavaScript type conversions (parseInt).
Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt).
Interface returns the object converted to interface{}. See table in package comment for details.
Invoke calls the object itself. This will fail if it is not a function.
Length returns the object's "length" property, converted to int.
New creates a new instance of this type object. This will fail if it not a function (constructor).
Set assigns the value to the object's property with the given key.
SetIndex sets the i'th element of an array.
String returns the object converted to string according to JavaScript type conversions.
Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt).
Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use.
type S []interface{}
S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion).
Package js is imported by 558 packages. Updated 2018-04-16. Refresh now. Tools for package owners.