MCPcopy Create free account
hub / github.com/dop251/goja / setOwnStr

Method setOwnStr

object_gomap_reflect.go:126–149  ·  view source on GitHub ↗
(name unistring.String, val Value, throw bool)

Source from the content-addressed store, hash-verified

124}
125
126func (o *objectGoMapReflect) setOwnStr(name unistring.String, val Value, throw bool) bool {
127 n := name.String()
128 key := o.strToKey(n, false)
129 if !key.IsValid() || !o.fieldsValue.MapIndex(key).IsValid() {
130 if proto := o.prototype; proto != nil {
131 // we know it's foreign because prototype loops are not allowed
132 if res, ok := proto.self.setForeignStr(name, val, o.val, throw); ok {
133 return res
134 }
135 }
136 // new property
137 if !o.extensible {
138 o.val.runtime.typeErrorResult(throw, "Cannot add property %s, object is not extensible", n)
139 return false
140 } else {
141 if throw && !key.IsValid() {
142 o.strToKey(n, true)
143 return false
144 }
145 }
146 }
147 o._put(key, val, throw)
148 return true
149}
150
151func (o *objectGoMapReflect) setOwnIdx(idx valueInt, val Value, throw bool) bool {
152 key := o.toKey(idx, false)

Callers

nothing calls this directly

Calls 5

strToKeyMethod · 0.95
_putMethod · 0.95
typeErrorResultMethod · 0.80
StringMethod · 0.65
setForeignStrMethod · 0.65

Tested by

no test coverage detected