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

Method setOwnStr

object_gomap.go:43–63  ·  view source on GitHub ↗
(name unistring.String, val Value, throw bool)

Source from the content-addressed store, hash-verified

41}
42
43func (o *objectGoMapSimple) setOwnStr(name unistring.String, val Value, throw bool) bool {
44 n := name.String()
45 if _, exists := o.data[n]; exists {
46 o.data[n] = val.Export()
47 return true
48 }
49 if proto := o.prototype; proto != nil {
50 // we know it's foreign because prototype loops are not allowed
51 if res, ok := proto.self.setForeignStr(name, val, o.val, throw); ok {
52 return res
53 }
54 }
55 // new property
56 if !o.extensible {
57 o.val.runtime.typeErrorResult(throw, "Cannot add property %s, object is not extensible", name)
58 return false
59 } else {
60 o.data[n] = val.Export()
61 }
62 return true
63}
64
65func trueValIfPresent(present bool) Value {
66 if present {

Callers

nothing calls this directly

Calls 4

typeErrorResultMethod · 0.80
StringMethod · 0.65
ExportMethod · 0.65
setForeignStrMethod · 0.65

Tested by

no test coverage detected