(call FunctionCall)
| 336 | } |
| 337 | |
| 338 | func (r *Runtime) arrayproto_slice(call FunctionCall) Value { |
| 339 | o := call.This.ToObject(r) |
| 340 | length := toLength(o.self.getStr("length", nil)) |
| 341 | start := relToIdx(call.Argument(0).ToInteger(), length) |
| 342 | var end int64 |
| 343 | if endArg := call.Argument(1); endArg != _undefined { |
| 344 | end = endArg.ToInteger() |
| 345 | } else { |
| 346 | end = length |
| 347 | } |
| 348 | end = relToIdx(end, length) |
| 349 | |
| 350 | count := end - start |
| 351 | if count < 0 { |
| 352 | count = 0 |
| 353 | } |
| 354 | |
| 355 | a := arraySpeciesCreate(o, count) |
| 356 | if src := r.checkStdArrayObj(o); src != nil { |
| 357 | if dst := r.checkStdArrayObjWithProto(a); dst != nil { |
| 358 | values := make([]Value, count) |
| 359 | copy(values, src.values[start:]) |
| 360 | setArrayValues(dst, values) |
| 361 | return a |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | n := int64(0) |
| 366 | for start < end { |
| 367 | p := o.self.getIdx(valueInt(start), nil) |
| 368 | if p != nil { |
| 369 | createDataPropertyOrThrow(a, valueInt(n), p) |
| 370 | } |
| 371 | start++ |
| 372 | n++ |
| 373 | } |
| 374 | return a |
| 375 | } |
| 376 | |
| 377 | func (r *Runtime) arrayproto_sort(call FunctionCall) Value { |
| 378 | o := call.This.ToObject(r) |
nothing calls this directly
no test coverage detected