(call FunctionCall)
| 1043 | } |
| 1044 | |
| 1045 | func (r *Runtime) arrayproto_copyWithin(call FunctionCall) Value { |
| 1046 | o := call.This.ToObject(r) |
| 1047 | l := toLength(o.self.getStr("length", nil)) |
| 1048 | var relEnd, dir int64 |
| 1049 | to := relToIdx(call.Argument(0).ToInteger(), l) |
| 1050 | from := relToIdx(call.Argument(1).ToInteger(), l) |
| 1051 | if end := call.Argument(2); end != _undefined { |
| 1052 | relEnd = end.ToInteger() |
| 1053 | } else { |
| 1054 | relEnd = l |
| 1055 | } |
| 1056 | final := relToIdx(relEnd, l) |
| 1057 | count := min(final-from, l-to) |
| 1058 | if arr := r.checkStdArrayObj(o); arr != nil { |
| 1059 | if count > 0 { |
| 1060 | copy(arr.values[to:to+count], arr.values[from:from+count]) |
| 1061 | } |
| 1062 | return o |
| 1063 | } |
| 1064 | if from < to && to < from+count { |
| 1065 | dir = -1 |
| 1066 | from = from + count - 1 |
| 1067 | to = to + count - 1 |
| 1068 | } else { |
| 1069 | dir = 1 |
| 1070 | } |
| 1071 | for count > 0 { |
| 1072 | if o.self.hasPropertyIdx(valueInt(from)) { |
| 1073 | o.self.setOwnIdx(valueInt(to), nilSafe(o.self.getIdx(valueInt(from), nil)), true) |
| 1074 | } else { |
| 1075 | o.self.deleteIdx(valueInt(to), true) |
| 1076 | } |
| 1077 | from += dir |
| 1078 | to += dir |
| 1079 | count-- |
| 1080 | } |
| 1081 | |
| 1082 | return o |
| 1083 | } |
| 1084 | |
| 1085 | func (r *Runtime) arrayproto_entries(call FunctionCall) Value { |
| 1086 | return r.createArrayIterator(call.This.ToObject(r), iterationKindKeyValue) |
nothing calls this directly
no test coverage detected