new Collection()
Provides the sortable, iterable storage of entities that are
gettable, settable, sortable, removable, etcera(ble) by name
- Source:
Methods
-
addItem(item, name)
-
Add an item with optional name
Parameters:
Name Type Argument Description itemAny The item to add
nameString <optional>
The optional name of the item
- Source:
Returns:
- Type
- Collection
-
addItems(items)
-
Add multiple items
Parameters:
Name Type Argument Description itemsObject <repeatable>
Can be the object itself or an object containing the entity and it's name
eg:{ item: Entity, name: 'entityName' }- Source:
Returns:
- Type
- Collection
-
each(fn, scope)
-
Iterates the collection's sorted items. The item, index, and name are supplied
to the provided functionParameters:
Name Type Argument Description fnfunction The function to execute on the iterable
scopeObject <optional>
The scope with which to execute the function
- Source:
-
filter(fn, scope)
-
iterates items and return the ones that meet criteria
Parameters:
Name Type Argument Description fnfunction Truth predicate
scopeObject <optional>
The scope with which to execute the function
- Source:
Returns:
- Type
- Array
-
getItem(name)
-
Returns an existing item by name, or undefined if the name is not found
Parameters:
Name Type Description nameString The name of the item
- Source:
Returns:
- Type
- Any
-
getItemArray()
-
Returns a list of just the items
- Source:
Returns:
- Type
- Array
-
getItemAt(index)
-
Returns an existing item by index
Parameters:
Name Type Description indexInteger - Source:
Returns:
- Type
- Any
-
getItemCount()
-
Returns the count of items in collection
- Source:
Returns:
- Type
- Integer
-
getItemIndex(name)
-
Returns an item's current index
Parameters:
Name Type Description nameString - Source:
Returns:
- Type
- Integer
-
removeAllItems()
-
Removes all items from collection
- Source:
-
setItem(name, value)
-
Assigns a new value to an existing item
Parameters:
Name Type Description nameString The name of the object to modify
valueAny The new value
- Source:
-
setItemIndex(name, index)
-
Moves item to new index
Parameters:
Name Type Description nameString The name of the object being moved
indexInteger The item's new index
- Source: