List
A list of items that can be read and updated.
Type Parameters
• S
• M
Methods
count
function
Gets the number of items in the list.
Returns
The number of items.
number
toArray
function
Converts the list to an array.
Returns
An array containing all items. The items are the same as in the list.
readonly M
[]
forEach
function
Executes a function for each item in the list.
Parameters
callback
ForEachCallback<M>
The function to run for each item.
Parameters
item
M
The current item in the list.
index
number
The index of the current item.
Returns
void
Returns
void
filter
function
Creates a new array with items that pass a test.
Parameters
filter
FilterPredicate<M>
A function that tests each item. Returns true
to keep the item.
Parameters
item
M
The item to test.
Returns
true
if the item should be included, otherwise false
.
boolean
Returns
An array of items that passed the test.
readonly M
[]
insertBefore
function
Adds a copy of an item to the list and places it right before another item.
Parameters
ref
undefined | M
The existing item to place the new item before.
If ref
is undefined
, the new item is added at the end of the list.
If ref
does not exist in the list, the operation fails.
item
S
The item to add. A copy of this item will be inserted.
Returns
The added item, or undefined
if the operation failed.
undefined | M
insertAfter
function
Adds a copy of an item to the list and places it right after another item.
Parameters
ref
undefined | M
The existing item to place the new item after.
If ref
is undefined
, the new item is added at the end of the list.
If ref
does not exist in the list, the operation fails.
item
S
The item to add. A copy of this item will be inserted.
Returns
The added item, or undefined
if the operation failed.
undefined | M
moveBefore
function
Moves an existing item to a new position right before another item.
Parameters
ref
undefined | M
The existing item to move the item before.
If ref
is undefined
, the item is moved to the end of the list.
If ref
does not exist in the list, the operation fails.
item
M
The item to move. The operation fails if the item is not already in the list.
Returns
void
moveAfter
function
Moves an existing item to a new position right after another item.
Parameters
ref
undefined | M
The existing item to move the item after.
If ref
is undefined
, the item is moved to the end of the list.
If ref
does not exist in the list, the operation fails.
item
M
The item to move. The operation fails if the item is not already in the list.
Returns
void
delete
function
Removes an item from the list.
Parameters
item
M
The item to remove from the list.
Returns
void