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

Method ToIndex

value.go:249–260  ·  view source on GitHub ↗

ToIndex returns the value converted to a JavaScript array index.

()

Source from the content-addressed store, hash-verified

247
248// ToIndex returns the value converted to a JavaScript array index.
249func (v *Value) ToIndex() (uint64, error) {
250 if !v.hasValidContext() {
251 return 0, errors.New("value context is not available")
252 }
253
254 val := C.uint64_t(0)
255 if C.JS_ToIndex(v.ctx.ref, &val, v.ref) != 0 {
256 return 0, v.ctx.Exception()
257 }
258
259 return uint64(val), nil
260}
261
262// ToBigInt64 returns the value converted to int64 using BigInt semantics.
263func (v *Value) ToBigInt64() (int64, error) {

Callers 1

Calls 3

hasValidContextMethod · 0.95
NewMethod · 0.80
ExceptionMethod · 0.80

Tested by 1