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

Method _setLengthInt

array_sparse.go:33–67  ·  view source on GitHub ↗
(l uint32, throw bool)

Source from the content-addressed store, hash-verified

31}
32
33func (a *sparseArrayObject) _setLengthInt(l uint32, throw bool) bool {
34 ret := true
35 if l <= a.length {
36 if a.propValueCount > 0 {
37 // Slow path
38 for i := len(a.items) - 1; i >= 0; i-- {
39 item := a.items[i]
40 if item.idx <= l {
41 break
42 }
43 if prop, ok := item.value.(*valueProperty); ok {
44 if !prop.configurable {
45 l = item.idx + 1
46 ret = false
47 break
48 }
49 a.propValueCount--
50 }
51 }
52 }
53 }
54
55 idx := a.findIdx(l)
56
57 aa := a.items[idx:]
58 for i := range aa {
59 aa[i].value = nil
60 }
61 a.items = a.items[:idx]
62 a.length = l
63 if !ret {
64 a.val.runtime.typeErrorResult(throw, "Cannot redefine property: length")
65 }
66 return ret
67}
68
69func (a *sparseArrayObject) setLengthInt(l uint32, throw bool) bool {
70 if l == a.length {

Callers 2

setLengthIntMethod · 0.95
setLengthMethod · 0.95

Calls 2

findIdxMethod · 0.95
typeErrorResultMethod · 0.80

Tested by

no test coverage detected