Class: RestrictedItemList<T>
Base for ItemLists that restrict how items are added to the list, but freely allow items to be removed and reordered. The ItemList subclass adds more capabilities, however.
Extends
Extended by
Type Parameters
T extends ListItemConstructors
Constructor
new RestrictedItemList<T>(): RestrictedItemList<T>;
Returns
RestrictedItemList<T>
Inherited from
Accessors
length
Get Signature
get length(): number;
Number of items in this list.
Returns
number
Inherited from
first
Get Signature
get first(): T | undefined;
First item in this list, or undefined if list is empty.
Returns
T | undefined
Inherited from
last
Get Signature
get last(): T | undefined;
Last item in this list, or undefined if list is empty.
Returns
T | undefined
Inherited from
Methods
indexOf()
indexOf(item): number;
Get index of item in list.
Parameters
itemTReturns
number
index number, or -1 if item isn't in this list.
Inherited from
item()
item(index): T | undefined;
Returns item at the given index, or undefined if index is out of range.
Parameters
indexnumberReturns
T | undefined
Inherited from
[iterator]()
iterator: Iterator<T>;
Iterates over all the items in this list. Mutations that occur mid-iteration are not reflected by the iterator.
Returns
Iterator<T>
Inherited from
toArray()
toArray(): readonly T[];
All items in the list, as a static array. Mutations that occur later are not reflected in an array returned earlier.
Returns
readonly T[]
Inherited from
remove()
remove(...items): void;
Remove the items from the list. The items need not be contiguous.
Parameters
itemsT[]Returns
void
Throws
If any of the items are not in the list, or if it is illegal to remove any of the items from this parent.
moveBefore()
moveBefore(item, before): void;
Move item so it is immediately before before in this list: places item at the index that before used to occupy. Depending on the position in the list item originally occupied, some other items in the list may shift to higher or lower indices as a result. No-op if both arguments are the same item.
Parameters
itemTbeforeTReturns
void
Throws
An error if either argument is not contained in this list.
moveAfter()
moveAfter(item, after): void;
Move item so it is immediately after after in this list: places item at the index one higher than after. Depending on the position in the list item originally occupied, some other items in the list may shift to higher or lower indices as a result. No-op if both arguments are the same item.
Parameters
itemTafterTReturns
void
Throws
An error if either argument is not contained in this list.