(call FunctionCall)
| 996 | } |
| 997 | |
| 998 | func (r *Runtime) arrayproto_shift(call FunctionCall) Value { |
| 999 | o := call.This.ToObject(r) |
| 1000 | if a := r.checkStdArrayObjWithProto(o); a != nil { |
| 1001 | if len(a.values) == 0 { |
| 1002 | if !a.lengthProp.writable { |
| 1003 | a.setLength(0, true) // will throw |
| 1004 | } |
| 1005 | return _undefined |
| 1006 | } |
| 1007 | first := a.values[0] |
| 1008 | copy(a.values, a.values[1:]) |
| 1009 | a.values[len(a.values)-1] = nil |
| 1010 | a.values = a.values[:len(a.values)-1] |
| 1011 | a.length-- |
| 1012 | return first |
| 1013 | } |
| 1014 | length := toLength(o.self.getStr("length", nil)) |
| 1015 | if length == 0 { |
| 1016 | o.self.setOwnStr("length", intToValue(0), true) |
| 1017 | return _undefined |
| 1018 | } |
| 1019 | first := o.self.getIdx(valueInt(0), nil) |
| 1020 | for i := int64(1); i < length; i++ { |
| 1021 | idxFrom := valueInt(i) |
| 1022 | idxTo := valueInt(i - 1) |
| 1023 | if o.self.hasPropertyIdx(idxFrom) { |
| 1024 | o.self.setOwnIdx(idxTo, nilSafe(o.self.getIdx(idxFrom, nil)), true) |
| 1025 | } else { |
| 1026 | o.self.deleteIdx(idxTo, true) |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | lv := valueInt(length - 1) |
| 1031 | o.self.deleteIdx(lv, true) |
| 1032 | o.self.setOwnStr("length", lv, true) |
| 1033 | |
| 1034 | return first |
| 1035 | } |
| 1036 | |
| 1037 | func (r *Runtime) arrayproto_values(call FunctionCall) Value { |
| 1038 | return r.createArrayIterator(call.This.ToObject(r), iterationKindValue) |
nothing calls this directly
no test coverage detected