(idx uint32, desc PropertyDescriptor, throw bool)
| 337 | } |
| 338 | |
| 339 | func (a *sparseArrayObject) _defineIdxProperty(idx uint32, desc PropertyDescriptor, throw bool) bool { |
| 340 | var existing Value |
| 341 | i := a.findIdx(idx) |
| 342 | if i < len(a.items) && a.items[i].idx == idx { |
| 343 | existing = a.items[i].value |
| 344 | } |
| 345 | prop, ok := a.baseObject._defineOwnProperty(unistring.String(strconv.FormatUint(uint64(idx), 10)), existing, desc, throw) |
| 346 | if ok { |
| 347 | if idx >= a.length { |
| 348 | if !a.setLengthInt(idx+1, throw) { |
| 349 | return false |
| 350 | } |
| 351 | } |
| 352 | if i >= len(a.items) || a.items[i].idx != idx { |
| 353 | if a.expand(idx) { |
| 354 | a.items = append(a.items, sparseArrayItem{}) |
| 355 | copy(a.items[i+1:], a.items[i:]) |
| 356 | a.items[i] = sparseArrayItem{ |
| 357 | idx: idx, |
| 358 | value: prop, |
| 359 | } |
| 360 | if idx >= a.length { |
| 361 | a.length = idx + 1 |
| 362 | } |
| 363 | } else { |
| 364 | a.val.self.(*arrayObject).values[idx] = prop |
| 365 | } |
| 366 | } else { |
| 367 | a.items[i].value = prop |
| 368 | } |
| 369 | if _, ok := prop.(*valueProperty); ok { |
| 370 | a.propValueCount++ |
| 371 | } |
| 372 | } |
| 373 | return ok |
| 374 | } |
| 375 | |
| 376 | func (a *sparseArrayObject) defineOwnPropertyStr(name unistring.String, descr PropertyDescriptor, throw bool) bool { |
| 377 | if idx := strToArrayIdx(name); idx != math.MaxUint32 { |
no test coverage detected