| 578 | }, |
| 579 | |
| 580 | splice(index, removeNum /*, ...values*/) { |
| 581 | const numArgs = arguments.length; |
| 582 | removeNum = Math.max(removeNum || 0, 0); |
| 583 | if (numArgs === 0 || (numArgs === 2 && !removeNum)) { |
| 584 | return this; |
| 585 | } |
| 586 | // If index is negative, it should resolve relative to the size of the |
| 587 | // collection. However size may be expensive to compute if not cached, so |
| 588 | // only call count() if the number is in fact negative. |
| 589 | index = resolveBegin(index, index < 0 ? this.count() : this.size); |
| 590 | const spliced = this.slice(0, index); |
| 591 | return reify( |
| 592 | this, |
| 593 | numArgs === 1 |
| 594 | ? spliced |
| 595 | : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) |
| 596 | ); |
| 597 | }, |
| 598 | |
| 599 | // ### More collection methods |
| 600 | |