MCPcopy Create free account
hub / github.com/buke/quickjs-go / ToNumber

Method ToNumber

value.go:235–246  ·  view source on GitHub ↗

ToNumber returns the numeric value as a new JavaScript Number.

()

Source from the content-addressed store, hash-verified

233
234// ToNumber returns the numeric value as a new JavaScript Number.
235func (v *Value) ToNumber() (*Value, error) {
236 if !v.hasValidContext() {
237 return nil, errors.New("value context is not available")
238 }
239
240 converted := &Value{ctx: v.ctx, ref: C.JS_ToNumber(v.ctx.ref, v.ref)}
241 if converted.IsException() {
242 return nil, v.ctx.Exception()
243 }
244
245 return converted, nil
246}
247
248// ToIndex returns the value converted to a JavaScript array index.
249func (v *Value) ToIndex() (uint64, error) {

Callers 1

Calls 4

hasValidContextMethod · 0.95
IsExceptionMethod · 0.95
NewMethod · 0.80
ExceptionMethod · 0.80

Tested by 1