insertMany replaced insertArray and insertList while also changing the return value:
insertArray(index: number, values: Array<T>): boolean
// vs
insertMany(index: number, values: Iterable<T>): this
This is done by clamping the index to be from 0 to this.length, so any negative indeces become 0 and thus values are added to the start of the list, and the same for indeces larger than this.length adding to the end.
That frees up the return value, which previously reported on whether the index was accepted. My proposal is to apply this logic to every other function with a similar index parameter by implementing the following method to use on every index parameter:
private clampIndex(index: number) {
if (index < 0) return 0;
if (index > this.length) return this.length;
return Math.trunc(index);
}
insertManyreplacedinsertArrayandinsertListwhile also changing the return value:This is done by clamping the index to be from
0tothis.length, so any negative indeces become0and thus values are added to the start of the list, and the same for indeces larger thanthis.lengthadding to the end.That frees up the return value, which previously reported on whether the index was accepted. My proposal is to apply this logic to every other function with a similar index parameter by implementing the following method to use on every index parameter: