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

Method OwnProperty

value.go:687–707  ·  view source on GitHub ↗

OwnProperty gets a full own property descriptor by name.

(name string)

Source from the content-addressed store, hash-verified

685
686// OwnProperty gets a full own property descriptor by name.
687func (v *Value) OwnProperty(name string) (*PropertyDescriptor, bool) {
688 if !v.isAlive() {
689 return nil, false
690 }
691 atom := v.ctx.NewAtom(name)
692 defer atom.Free()
693
694 var desc C.JSPropertyDescriptor
695 ret := C.JS_GetOwnProperty(v.ctx.ref, &desc, v.ref, atom.ref)
696 if ret <= 0 {
697 return nil, false
698 }
699
700 result := &PropertyDescriptor{
701 Flags: int(desc.flags),
702 Value: &Value{ctx: v.ctx, ref: desc.value},
703 Getter: &Value{ctx: v.ctx, ref: desc.getter},
704 Setter: &Value{ctx: v.ctx, ref: desc.setter},
705 }
706 return result, true
707}
708
709// GetAtom gets a property by atom key.
710func (v *Value) GetAtom(atom *Atom) *Value {

Calls 3

isAliveMethod · 0.95
FreeMethod · 0.95
NewAtomMethod · 0.80