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

Method arrayproto_fill

builtin_array.go:1089–1111  ·  view source on GitHub ↗
(call FunctionCall)

Source from the content-addressed store, hash-verified

1087}
1088
1089func (r *Runtime) arrayproto_fill(call FunctionCall) Value {
1090 o := call.This.ToObject(r)
1091 l := toLength(o.self.getStr("length", nil))
1092 k := relToIdx(call.Argument(1).ToInteger(), l)
1093 var relEnd int64
1094 if endArg := call.Argument(2); endArg != _undefined {
1095 relEnd = endArg.ToInteger()
1096 } else {
1097 relEnd = l
1098 }
1099 final := relToIdx(relEnd, l)
1100 value := call.Argument(0)
1101 if arr := r.checkStdArrayObj(o); arr != nil {
1102 for ; k < final; k++ {
1103 arr.values[k] = value
1104 }
1105 } else {
1106 for ; k < final; k++ {
1107 o.self.setOwnIdx(valueInt(k), value, true)
1108 }
1109 }
1110 return o
1111}
1112
1113func (r *Runtime) arrayproto_find(call FunctionCall) Value {
1114 o := call.This.ToObject(r)

Callers

nothing calls this directly

Calls 9

checkStdArrayObjMethod · 0.95
toLengthFunction · 0.85
relToIdxFunction · 0.85
valueIntTypeAlias · 0.85
ToObjectMethod · 0.65
getStrMethod · 0.65
ToIntegerMethod · 0.65
setOwnIdxMethod · 0.65
ArgumentMethod · 0.45

Tested by

no test coverage detected