Creates an ordered array of the values of this collection, and caches it internally. The array will only be
reconstructed if an item is added to or removed from the collection, or if you change the length of the array
itself. If you don't want this caching behavior, use [...collection.values()]
or
Array.from(collection.values())
instead.
Creates an identical shallow copy of this collection.
Combines this collection with others into a new collection. None of the source collections are modified.
Collections to merge
Identical to Map.forEach(), but returns the collection instead of undefined.
Function to execute for each element
Checks if this collection shares identical key-value pairings with another. This is different to checking for equality using equal-signs, because the collections may be different objects, but contain the same data.
Collection to compare with
Whether the collections have identical contents
Checks if all items passes a test. Identical in behavior to Array.every().
Function used to test (should return a boolean)
Identical to Array.filter(), but returns a Collection instead of an Array.
The function to test with (should return boolean)
Searches for a single item where the given function returns a truthy value. This behaves like
Array.find().
id
property, and if you want to find by id you
should use the get
method. See
MDN for details.
The function to test with (should return boolean)
Searches for the key of a single item where the given function returns a truthy value. This behaves like Array.findIndex(), but returns the key rather than the positional index.
The function to test with (should return boolean)
Obtains the first key(s) in this collection.
A single key if no amount is provided or an array of keys, starting from the end if amount is negative
boolean indicating whether an element with the specified key exists or not.
Creates an ordered array of the keys of this collection, and caches it internally. The array will only be
reconstructed if an item is added to or removed from the collection, or if you change the length of the array
itself. If you don't want this caching behavior, use [...collection.keys()]
or
Array.from(collection.keys())
instead.
Obtains the last value(s) in this collection. This relies on {@link Collection#array}, and thus the caching mechanism applies here as well.
A single value if no amount is provided or an array of values, starting from the start if amount is negative
Obtains the last key(s) in this collection. This relies on {@link Collection#keyArray}, and thus the caching mechanism applies here as well.
A single key if no amount is provided or an array of keys, starting from the start if amount is negative
Maps each item to another value into an array. Identical in behavior to Array.map().
Function that produces an element of the new array, taking three arguments
Maps each item to another value into a collection. Identical in behavior to Array.map().
Function that produces an element of the new collection, taking three arguments
Obtains unique random key(s) from this collection. This relies on {@link Collection#keyArray}, and thus the caching mechanism applies here as well.
A single key if no amount is provided or an array
Applies a function to produce a single value. Identical in behavior to Array.reduce().
Function used to reduce, taking four arguments; accumulator
, currentValue
, currentKey
,
and collection
Checks if there exists an item that passes a test. Identical in behavior to Array.some().
Function used to test (should return a boolean)
The sort() method sorts the elements of a collection and returns it. The sort is not necessarily stable. The default sort order is according to string Unicode code points.
Runs a function on the collection and returns the collection.
Function to execute
the number of elements in the Map.