generated from foxkit-js/library-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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>): thisThis 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);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Ideas