Documentation
¶
Overview ¶
Package v8go provides an API to execute JavaScript.
Index ¶
- func JSONStringify(ctx *Context, val Valuer) (string, error)
- func SetFlags(flags ...string)
- func Version() string
- type Context
- type ContextOption
- type Function
- type FunctionCallback
- type FunctionCallbackInfo
- type FunctionTemplate
- type HeapStatistics
- type Isolate
- type JSError
- type Object
- func (o *Object) Delete(key string) bool
- func (o *Object) DeleteIdx(idx uint32) bool
- func (o *Object) Get(key string) (*Value, error)
- func (o *Object) GetIdx(idx uint32) (*Value, error)
- func (o *Object) Has(key string) bool
- func (o *Object) HasIdx(idx uint32) bool
- func (o *Object) Set(key string, val interface{}) error
- func (o *Object) SetIdx(idx uint32, val interface{}) error
- type ObjectTemplate
- type Promise
- type PromiseResolver
- type PromiseState
- type PropertyAttribute
- type Value
- func (v *Value) ArrayIndex() (idx uint32, ok bool)
- func (v *Value) AsFunction() (*Function, error)
- func (v *Value) AsObject() (*Object, error)
- func (v *Value) AsPromise() (*Promise, error)
- func (v *Value) BigInt() *big.Int
- func (v *Value) Boolean() bool
- func (v *Value) DetailString() string
- func (v *Value) Format(s fmt.State, verb rune)
- func (v *Value) Int32() int32
- func (v *Value) Integer() int64
- func (v *Value) IsArgumentsObject() bool
- func (v *Value) IsArray() bool
- func (v *Value) IsArrayBuffer() bool
- func (v *Value) IsArrayBufferView() bool
- func (v *Value) IsAsyncFunction() bool
- func (v *Value) IsBigInt() bool
- func (v *Value) IsBigInt64Array() bool
- func (v *Value) IsBigIntObject() bool
- func (v *Value) IsBigUint64Array() bool
- func (v *Value) IsBoolean() bool
- func (v *Value) IsDataView() bool
- func (v *Value) IsDate() bool
- func (v *Value) IsExternal() bool
- func (v *Value) IsFalse() bool
- func (v *Value) IsFloat32Array() bool
- func (v *Value) IsFloat64Array() bool
- func (v *Value) IsFunction() bool
- func (v *Value) IsGeneratorFunction() bool
- func (v *Value) IsGeneratorObject() bool
- func (v *Value) IsInt16Array() bool
- func (v *Value) IsInt32() bool
- func (v *Value) IsInt32Array() bool
- func (v *Value) IsInt8Array() bool
- func (v *Value) IsMap() bool
- func (v *Value) IsMapIterator() bool
- func (v *Value) IsModuleNamespaceObject() bool
- func (v *Value) IsName() bool
- func (v *Value) IsNativeError() bool
- func (v *Value) IsNull() bool
- func (v *Value) IsNullOrUndefined() bool
- func (v *Value) IsNumber() bool
- func (v *Value) IsNumberObject() bool
- func (v *Value) IsObject() bool
- func (v *Value) IsPromise() bool
- func (v *Value) IsProxy() bool
- func (v *Value) IsRegExp() bool
- func (v *Value) IsSet() bool
- func (v *Value) IsSetIterator() bool
- func (v *Value) IsSharedArrayBuffer() bool
- func (v *Value) IsString() bool
- func (v *Value) IsStringObject() bool
- func (v *Value) IsSymbol() bool
- func (v *Value) IsSymbolObject() bool
- func (v *Value) IsTrue() bool
- func (v *Value) IsTypedArray() bool
- func (v *Value) IsUint16Array() bool
- func (v *Value) IsUint32() bool
- func (v *Value) IsUint32Array() bool
- func (v *Value) IsUint8Array() bool
- func (v *Value) IsUint8ClampedArray() bool
- func (v *Value) IsUndefined() bool
- func (v *Value) IsWasmModuleObject() bool
- func (v *Value) IsWeakMap() bool
- func (v *Value) IsWeakSet() bool
- func (v *Value) MarshalJSON() ([]byte, error)
- func (v *Value) Number() float64
- func (v *Value) Object() *Object
- func (v *Value) String() string
- func (v *Value) Uint32() uint32
- type Valuer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONStringify ¶
JSONStringify tries to stringify the JSON-serializable object value and returns it as string.
Example ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { ctx, _ := v8go.NewContext() val, _ := v8go.JSONParse(ctx, `{ "a": 1, "b": "foo" }`) jsonStr, _ := v8go.JSONStringify(ctx, val) fmt.Println(jsonStr) }
Output: {"a":1,"b":"foo"}
func SetFlags ¶
func SetFlags(flags ...string)
SetFlags sets flags for V8. For possible flags: https://github.com/v8/v8/blob/master/src/flags/flag-definitions.h Flags are expected to be prefixed with `--`, for example: `--harmony`. Flags can be reverted using the `--no` prefix equivalent, for example: `--use_strict` vs `--nouse_strict`. Flags will affect all Isolates created, even after creation.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a global root execution environment that allows separate, unrelated, JavaScript applications to run in a single instance of V8.
Example ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { ctx, _ := v8go.NewContext() ctx.RunScript("const add = (a, b) => a + b", "math.js") ctx.RunScript("const result = add(3, 4)", "main.js") val, _ := ctx.RunScript("result", "value.js") fmt.Println(val) }
Output: 7
Example (GlobalTemplate) ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { iso, _ := v8go.NewIsolate() obj, _ := v8go.NewObjectTemplate(iso) obj.Set("version", "v1.0.0") ctx, _ := v8go.NewContext(iso, obj) val, _ := ctx.RunScript("version", "main.js") fmt.Println(val) }
Output: v1.0.0
Example (Isolate) ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { iso, _ := v8go.NewIsolate() ctx1, _ := v8go.NewContext(iso) ctx1.RunScript("const foo = 'bar'", "context_one.js") val, _ := ctx1.RunScript("foo", "foo.js") fmt.Println(val) ctx2, _ := v8go.NewContext(iso) _, err := ctx2.RunScript("foo", "context_two.js") fmt.Println(err) }
Output: bar ReferenceError: foo is not defined
func NewContext ¶
func NewContext(opt ...ContextOption) (*Context, error)
NewContext creates a new JavaScript context; if no Isolate is passed as a ContextOption than a new Isolate will be created.
func (*Context) Close ¶
func (c *Context) Close()
Close will dispose the context and free the memory. Access to any values assosiated with the context after calling Close may panic.
func (*Context) Global ¶
Global returns the global proxy object. Global proxy object is a thin wrapper whose prototype points to actual context's global object with the properties like Object, etc. This is done that way for security reasons. Please note that changes to global proxy object prototype most probably would break the VM — V8 expects only global object as a prototype of global proxy object.
func (*Context) Isolate ¶
Isolate gets the current context's parent isolate.An error is returned if the isolate has been terninated.
func (*Context) PerformMicrotaskCheckpoint ¶
func (c *Context) PerformMicrotaskCheckpoint()
PerformMicrotaskCheckpoint runs the default MicrotaskQueue until empty. This is used to make progress on Promises.
type ContextOption ¶
type ContextOption interface {
// contains filtered or unexported methods
}
ContextOption sets options such as Isolate and Global Template to the NewContext
type Function ¶
type Function struct {
*Value
}
Function is a JavaScript function.
type FunctionCallback ¶
type FunctionCallback func(info *FunctionCallbackInfo) *Value
FunctionCallback is a callback that is executed in Go when a function is executed in JS.
type FunctionCallbackInfo ¶
type FunctionCallbackInfo struct {
// contains filtered or unexported fields
}
FunctionCallbackInfo is the argument that is passed to a FunctionCallback.
func (*FunctionCallbackInfo) Args ¶
func (i *FunctionCallbackInfo) Args() []*Value
Args returns a slice of the value arguments that are passed to the JS function.
func (*FunctionCallbackInfo) Context ¶
func (i *FunctionCallbackInfo) Context() *Context
Context is the current context that the callback is being executed in.
type FunctionTemplate ¶
type FunctionTemplate struct {
// contains filtered or unexported fields
}
FunctionTemplate is used to create functions at runtime. There can only be one function created from a FunctionTemplate in a context. The lifetime of the created function is equal to the lifetime of the context.
Example ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { iso, _ := v8go.NewIsolate() global, _ := v8go.NewObjectTemplate(iso) printfn, _ := v8go.NewFunctionTemplate(iso, func(info *v8go.FunctionCallbackInfo) *v8go.Value { fmt.Printf("%+v\n", info.Args()) return nil }) global.Set("print", printfn, v8go.ReadOnly) ctx, _ := v8go.NewContext(iso, global) ctx.RunScript("print('foo', 'bar', 0, 1)", "") }
Output: [foo bar 0 1]
Example (Fetch) ¶
package main import ( "fmt" "io/ioutil" "net/http" "strings" "github.com/goenning/v8go" ) func main() { iso, _ := v8go.NewIsolate() global, _ := v8go.NewObjectTemplate(iso) fetchfn, _ := v8go.NewFunctionTemplate(iso, func(info *v8go.FunctionCallbackInfo) *v8go.Value { args := info.Args() url := args[0].String() resolver, _ := v8go.NewPromiseResolver(info.Context()) go func() { res, _ := http.Get(url) body, _ := ioutil.ReadAll(res.Body) val, _ := v8go.NewValue(iso, string(body)) resolver.Resolve(val) }() return resolver.GetPromise().Value }) global.Set("fetch", fetchfn, v8go.ReadOnly) ctx, _ := v8go.NewContext(iso, global) val, _ := ctx.RunScript("fetch('https://example.org/')", "") prom, _ := val.AsPromise() // wait for the promise to resolve for prom.State() == v8go.Pending { continue } fmt.Printf("%s\n", strings.Split(prom.Result().String(), "\n")[0]) }
Output: <!doctype html>
func NewFunctionTemplate ¶
func NewFunctionTemplate(iso *Isolate, callback FunctionCallback) (*FunctionTemplate, error)
NewFunctionTemplate creates a FunctionTemplate for a given callback.
func (*FunctionTemplate) GetFunction ¶
func (tmpl *FunctionTemplate) GetFunction(ctx *Context) *Function
GetFunction returns an instance of this function template bound to the given context.
func (FunctionTemplate) Set ¶
func (t FunctionTemplate) Set(name string, val interface{}, attributes ...PropertyAttribute) error
Set adds a property to each instance created by this template. The property must be defined either as a primitive value, or a template. If the value passed is a Go supported primitive (string, int32, uint32, int64, uint64, float64, big.Int) then a value will be created and set as the value property.
type HeapStatistics ¶
type HeapStatistics struct { TotalHeapSize uint64 TotalHeapSizeExecutable uint64 TotalPhysicalSize uint64 TotalAvailableSize uint64 UsedHeapSize uint64 HeapSizeLimit uint64 MallocedMemory uint64 ExternalMemory uint64 PeakMallocedMemory uint64 NumberOfNativeContexts uint64 NumberOfDetachedContexts uint64 }
HeapStatistics represents V8 isolate heap statistics
type Isolate ¶
type Isolate struct {
// contains filtered or unexported fields
}
Isolate is a JavaScript VM instance with its own heap and garbage collector. Most applications will create one isolate with many V8 contexts for execution.
func NewIsolate ¶
NewIsolate creates a new V8 isolate. Only one thread may access a given isolate at a time, but different threads may access different isolates simultaneously. When an isolate is no longer used its resources should be freed by calling iso.Dispose(). An *Isolate can be used as a v8go.ContextOption to create a new Context, rather than creating a new default Isolate.
func (*Isolate) Dispose ¶
func (i *Isolate) Dispose()
Dispose will dispose the Isolate VM; subsequent calls will panic.
func (*Isolate) GetHeapStatistics ¶
func (i *Isolate) GetHeapStatistics() HeapStatistics
GetHeapStatistics returns heap statistics for an isolate.
func (*Isolate) TerminateExecution ¶
func (i *Isolate) TerminateExecution()
TerminateExecution terminates forcefully the current thread of JavaScript execution in the given isolate.
type JSError ¶
JSError is an error that is returned if there is are any JavaScript exceptions handled in the context. When used with the fmt verb `%+v`, will output the JavaScript stack trace, if available.
type Object ¶
type Object struct {
*Value
}
Object is a JavaScript object (ECMA-262, 4.3.3)
Example (Global) ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { iso, _ := v8go.NewIsolate() ctx, _ := v8go.NewContext(iso) global := ctx.Global() console, _ := v8go.NewObjectTemplate(iso) logfn, _ := v8go.NewFunctionTemplate(iso, func(info *v8go.FunctionCallbackInfo) *v8go.Value { fmt.Println(info.Args()[0]) return nil }) console.Set("log", logfn) consoleObj, _ := console.NewInstance(ctx) global.Set("console", consoleObj) ctx.RunScript("console.log('foo')", "") }
Output: foo
func (*Object) Delete ¶
Delete returns true if successful in deleting a named property on the object.
func (*Object) DeleteIdx ¶
DeleteIdx returns true if successful in deleting a value at a given index of the object.
func (*Object) Has ¶
Has calls the abstract operation HasProperty(O, P) described in ECMA-262, 7.3.10. Returns true, if the object has the property, either own or on the prototype chain.
func (*Object) Set ¶
Set will set a property on the Object to a given value. Supports all value types, eg: Object, Array, Date, Set, Map etc If the value passed is a Go supported primitive (string, int32, uint32, int64, uint64, float64, big.Int) then a *Value will be created and set as the value property.
func (*Object) SetIdx ¶
Set will set a given index on the Object to a given value. Supports all value types, eg: Object, Array, Date, Set, Map etc If the value passed is a Go supported primitive (string, int32, uint32, int64, uint64, float64, big.Int) then a *Value will be created and set as the value property.
type ObjectTemplate ¶
type ObjectTemplate struct {
// contains filtered or unexported fields
}
ObjectTemplate is used to create objects at runtime. Properties added to an ObjectTemplate are added to each object created from the ObjectTemplate.
func NewObjectTemplate ¶
func NewObjectTemplate(iso *Isolate) (*ObjectTemplate, error)
NewObjectTemplate creates a new ObjectTemplate. The *ObjectTemplate can be used as a v8go.ContextOption to create a global object in a Context.
func (*ObjectTemplate) NewInstance ¶
func (o *ObjectTemplate) NewInstance(ctx *Context) (*Object, error)
NewInstance creates a new Object based on the template.
func (ObjectTemplate) Set ¶
func (t ObjectTemplate) Set(name string, val interface{}, attributes ...PropertyAttribute) error
Set adds a property to each instance created by this template. The property must be defined either as a primitive value, or a template. If the value passed is a Go supported primitive (string, int32, uint32, int64, uint64, float64, big.Int) then a value will be created and set as the value property.
type Promise ¶
type Promise struct {
*Object
}
Promise is the JavaScript promise object defined in ES6
func (*Promise) Catch ¶
func (p *Promise) Catch(cb FunctionCallback) *Promise
Catch invokes the given function if the promise is rejected. See Then for other details.
func (*Promise) Result ¶
Result is the value result of the Promise. The Promise must NOT be in a Pending state, otherwise may panic. Call promise.State() to validate state before calling for the result.
func (*Promise) State ¶
func (p *Promise) State() PromiseState
State returns the current state of the Promise.
func (*Promise) Then ¶
func (p *Promise) Then(cbs ...FunctionCallback) *Promise
Then accepts 1 or 2 callbacks. The first is invoked when the promise has been fulfilled. The second is invoked when the promise has been rejected. The returned Promise resolves after the callback finishes execution.
V8 only invokes the callback when processing "microtasks". The default MicrotaskPolicy processes them when the call depth decreases to 0. Call (*Context).PerformMicrotaskCheckpoint to trigger it manually.
type PromiseResolver ¶
type PromiseResolver struct { *Object // contains filtered or unexported fields }
PromiseResolver is the resolver object for the promise. Most cases will create a new PromiseResolver and return the associated Promise from the resolver.
func NewPromiseResolver ¶
func NewPromiseResolver(ctx *Context) (*PromiseResolver, error)
MewPromiseResolver creates a new Promise resolver for the given context. The associated Promise will be in a Pending state.
func (*PromiseResolver) GetPromise ¶
func (r *PromiseResolver) GetPromise() *Promise
GetPromise returns the associated Promise object for this resolver. The Promise object is unique to the resolver and returns the same object on multiple calls.
func (*PromiseResolver) Reject ¶
func (r *PromiseResolver) Reject(err *Value) bool
Reject invokes the Promise reject state with the given value. The Promise state will transition from Pending to Rejected.
func (*PromiseResolver) Resolve ¶
func (r *PromiseResolver) Resolve(val Valuer) bool
Resolve invokes the Promise resolve state with the given value. The Promise state will transition from Pending to Fulfilled.
type PromiseState ¶
type PromiseState int
PromiseState is the state of the Promise.
const ( Pending PromiseState = iota Fulfilled Rejected )
type PropertyAttribute ¶
type PropertyAttribute uint8
PropertyAttribute are the attribute flags for a property on an Object. Typical usage when setting an Object or TemplateObject property, and can also be validated when accessing a property.
const ( // None. None PropertyAttribute = 0 // ReadOnly, ie. not writable. ReadOnly PropertyAttribute = 1 << iota // DontEnum, ie. not enumerable. DontEnum // DontDelete, ie. not configurable. DontDelete )
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents all Javascript values and objects
func JSONParse ¶
JSONParse tries to parse the string and returns it as *Value if successful. Any JS errors will be returned as `JSError`.
Example ¶
package main import ( "fmt" "github.com/goenning/v8go" ) func main() { ctx, _ := v8go.NewContext() val, _ := v8go.JSONParse(ctx, `{"foo": "bar"}`) fmt.Println(val) }
Output: [object Object]
func NewValue ¶
NewValue will create a primitive value. Supported values types to create are:
string -> V8::String int32 -> V8::Integer uint32 -> V8::Integer bool -> V8::Boolean int64 -> V8::BigInt uint64 -> V8::BigInt bool -> V8::Boolean *big.Int -> V8::BigInt
func (*Value) ArrayIndex ¶
ArrayIndex attempts to converts a string to an array index. Returns ok false if conversion fails.
func (*Value) AsFunction ¶
func (*Value) AsObject ¶
AsObject will cast the value to the Object type. If the value is not an Object then an error is returned. Use `value.Object()` to do the JS equivalent of `Object(value)`.
func (*Value) Boolean ¶
Boolean perform the equivalent of `Boolean(value)` in JS. This can never fail.
func (*Value) DetailString ¶
DetailString provide a string representation of this value usable for debugging.
func (*Value) Format ¶
Format implements the fmt.Formatter interface to provide a custom formatter primarily to output the detail string (for debugging) with `%+v` verb.
func (*Value) Int32 ¶
Int32 perform the equivalent of `Number(value)` in JS and convert the result to a signed 32-bit integer by performing the steps in https://tc39.es/ecma262/#sec-toint32.
func (*Value) Integer ¶
Integer perform the equivalent of `Number(value)` in JS and convert the result to an integer. Negative values are rounded up, positive values are rounded down. NaN is converted to 0. Infinite values yield undefined results.
func (*Value) IsArgumentsObject ¶
IsArgumentsObject returns true if this value is an Arguments object.
func (*Value) IsArray ¶
IsArray returns true if this value is an array. Note that it will return false for a `Proxy` of an array.
func (*Value) IsArrayBuffer ¶
IsArrayBuffer returns true if this value is an `ArrayBuffer`.
func (*Value) IsArrayBufferView ¶
IsArrayBufferView returns true if this value is an `ArrayBufferView`.
func (*Value) IsAsyncFunction ¶
IsAsyncFunc returns true if this value is an async function.
func (*Value) IsBigInt ¶
IsBigInt returns true if this value is a bigint. This is equivalent to `typeof value === 'bigint'` in JS.
func (*Value) IsBigInt64Array ¶
IsBigInt64Array returns true if this value is a `BigInt64Array`.
func (*Value) IsBigIntObject ¶
IsBigIntObject returns true if this value is a BigInt object.
func (*Value) IsBigUint64Array ¶
IsBigUint64Array returns true if this value is a BigUint64Array`.
func (*Value) IsBoolean ¶
IsBoolean returns true if this value is boolean. This is equivalent to `typeof value === 'boolean'` in JS.
func (*Value) IsDataView ¶
IsDataView returns true if this value is a `DataView`.
func (*Value) IsExternal ¶
IsExternal returns true if this value is an `External` object.
func (*Value) IsFalse ¶
IsFalse returns true if this value is false. This is not the same as `!BooleanValue()`. The latter performs a conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas this checks `value === false`.
func (*Value) IsFloat32Array ¶
IsFloat32Array returns true if this value is a `Float32Array`.
func (*Value) IsFloat64Array ¶
IsFloat64Array returns true if this value is a `Float64Array`.
func (*Value) IsFunction ¶
IsFunction returns true if this value is a function. This is equivalent to `typeof value === 'function'` in JS.
func (*Value) IsGeneratorFunction ¶
Is IsGeneratorFunc returns true if this value is a Generator function.
func (*Value) IsGeneratorObject ¶
IsGeneratorObject returns true if this value is a Generator object (iterator).
func (*Value) IsInt16Array ¶
IsInt16Array returns true if this value is an `Int16Array`.
func (*Value) IsInt32Array ¶
IsInt32Array returns true if this value is an `Int32Array`.
func (*Value) IsInt8Array ¶
IsInt8Array returns true if this value is an `Int8Array`.
func (*Value) IsMapIterator ¶
IsMapIterator returns true if this value is a `Map` Iterator.
func (*Value) IsModuleNamespaceObject ¶
IsModuleNamespaceObject returns true if the value is a `Module` Namespace `Object`.
func (*Value) IsName ¶
IsName returns true if this value is a symbol or a string. This is equivalent to `typeof value === 'string' || typeof value === 'symbol'` in JS.
func (*Value) IsNativeError ¶
IsNativeError returns true if this value is a NativeError.
func (*Value) IsNullOrUndefined ¶
IsNullOrUndefined returns true if this value is either the null or the undefined value. See ECMA-262 4.3.11. and 4.3.12 This is equivalent to `value == null` in JS.
func (*Value) IsNumber ¶
IsNumber returns true if this value is a number. This is equivalent to `typeof value === 'number'` in JS.
func (*Value) IsNumberObject ¶
IsNumberObject returns true if this value is a `Number` object.
func (*Value) IsSetIterator ¶
IsSetIterator returns true if this value is a `Set` Iterator.
func (*Value) IsSharedArrayBuffer ¶
IsSharedArrayBuffer returns true if this value is a `SharedArrayBuffer`.
func (*Value) IsString ¶
IsString returns true if this value is an instance of the String type. See ECMA-262 8.4. This is equivalent to `typeof value === 'string'` in JS.
func (*Value) IsStringObject ¶
IsStringObject returns true if this value is a `String` object.
func (*Value) IsSymbol ¶
IsSymbol returns true if this value is a symbol. This is equivalent to `typeof value === 'symbol'` in JS.
func (*Value) IsSymbolObject ¶
IsSymbolObject returns true if this value is a `Symbol` object.
func (*Value) IsTrue ¶
IsTrue returns true if this value is true. This is not the same as `BooleanValue()`. The latter performs a conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas this checks `value === true`.
func (*Value) IsTypedArray ¶
IsTypedArray returns true if this value is one of TypedArrays.
func (*Value) IsUint16Array ¶
IsUint16Array returns true if this value is an `Uint16Array`.
func (*Value) IsUint32Array ¶
IsUint32Array returns true if this value is an `Uint32Array`.
func (*Value) IsUint8Array ¶
IsUint8Array returns true if this value is an `Uint8Array`.
func (*Value) IsUint8ClampedArray ¶
IsUint8ClampedArray returns true if this value is an `Uint8ClampedArray`.
func (*Value) IsUndefined ¶
IsUndefined returns true if this value is the undefined value. See ECMA-262 4.3.10.
func (*Value) IsWasmModuleObject ¶
IsWasmModuleObject returns true if this value is a `WasmModuleObject`.
func (*Value) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Value) Object ¶
Object perform the equivalent of Object(value) in JS. To just cast this value as an Object use AsObject() instead.
func (*Value) String ¶
String perform the equivalent of `String(value)` in JS. Primitive values are returned as-is, objects will return `[object Object]` and functions will print their definition.
func (*Value) Uint32 ¶
Uint32 perform the equivalent of `Number(value)` in JS and convert the result to an unsigned 32-bit integer by performing the steps in https://tc39.es/ecma262/#sec-touint32.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
deps
|
|
darwin_x86_64
Package darwin_x86_64 is required to provide support for vendoring modules DO NOT REMOVE
|
Package darwin_x86_64 is required to provide support for vendoring modules DO NOT REMOVE |
include
Package include is required to provide support for vendoring modules DO NOT REMOVE
|
Package include is required to provide support for vendoring modules DO NOT REMOVE |
include/cppgc
Package cppgc is required to provide support for vendoring modules DO NOT REMOVE
|
Package cppgc is required to provide support for vendoring modules DO NOT REMOVE |
include/libplatform
Package libplatform is required to provide support for vendoring modules DO NOT REMOVE
|
Package libplatform is required to provide support for vendoring modules DO NOT REMOVE |
linux_x86_64
Package linux_x86_64 is required to provide support for vendoring modules DO NOT REMOVE
|
Package linux_x86_64 is required to provide support for vendoring modules DO NOT REMOVE |