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

Method _defineIdxProperty

array.go:422–445  ·  view source on GitHub ↗
(idx uint32, desc PropertyDescriptor, throw bool)

Source from the content-addressed store, hash-verified

420}
421
422func (a *arrayObject) _defineIdxProperty(idx uint32, desc PropertyDescriptor, throw bool) bool {
423 var existing Value
424 if idx < uint32(len(a.values)) {
425 existing = a.values[idx]
426 }
427 prop, ok := a.baseObject._defineOwnProperty(unistring.String(strconv.FormatUint(uint64(idx), 10)), existing, desc, throw)
428 if ok {
429 if idx >= a.length {
430 if !a.setLengthInt(idx+1, throw) {
431 return false
432 }
433 }
434 if a.expand(idx) {
435 a.values[idx] = prop
436 a.objCount++
437 if _, ok := prop.(*valueProperty); ok {
438 a.propValueCount++
439 }
440 } else {
441 a.val.self.(*sparseArrayObject).add(idx, prop)
442 }
443 }
444 return ok
445}
446
447func (a *arrayObject) defineOwnPropertyStr(name unistring.String, descr PropertyDescriptor, throw bool) bool {
448 if idx := strToArrayIdx(name); idx != math.MaxUint32 {

Callers 2

defineOwnPropertyStrMethod · 0.95
defineOwnPropertyIdxMethod · 0.95

Calls 5

setLengthIntMethod · 0.95
expandMethod · 0.95
StringTypeAlias · 0.92
_defineOwnPropertyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected