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

Method _deleteIdxProp

array_sparse.go:393–408  ·  view source on GitHub ↗
(idx uint32, throw bool)

Source from the content-addressed store, hash-verified

391}
392
393func (a *sparseArrayObject) _deleteIdxProp(idx uint32, throw bool) bool {
394 i := a.findIdx(idx)
395 if i < len(a.items) && a.items[i].idx == idx {
396 if p, ok := a.items[i].value.(*valueProperty); ok {
397 if !p.configurable {
398 a.val.runtime.typeErrorResult(throw, "Cannot delete property '%d' of %s", idx, a.val.toString())
399 return false
400 }
401 a.propValueCount--
402 }
403 copy(a.items[i:], a.items[i+1:])
404 a.items[len(a.items)-1].value = nil
405 a.items = a.items[:len(a.items)-1]
406 }
407 return true
408}
409
410func (a *sparseArrayObject) deleteStr(name unistring.String, throw bool) bool {
411 if idx := strToArrayIdx(name); idx != math.MaxUint32 {

Callers 2

deleteStrMethod · 0.95
deleteIdxMethod · 0.95

Calls 3

findIdxMethod · 0.95
typeErrorResultMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected