An ordered collection of values with fast random access, push(...values)
, and pop()
, but can be slow to splice when sufficiently massive.
The shim-array
module provides extensions so it hosts all the expressiveness
of other collections. The shim-array
module shims some ECMAScript 5 methods
onto the array prototype if they are not natively implemented.
The number of items in this collection.
Adds values to the end of a collection.
Removes a value from the end of a collection, and returns that value.
Removes a value from the beginning of a collection, and returns that value.
Adds values to the beginning of a collection.
Returns the value at the beginning of a collection, the value that would be returned by shift()
.
Replaces the value at the beginning of a collection, the value that would be returned by shift()
.
Returns the value at the end of a collection, the value that would be returned by pop()
.
Replaces the value at the end of a collection, the value that would be returned by pop()
.
Whether an equivalent value exists in this collection.
Returns whether an equivalent value exists in this collection.
Deletes the first equivalent value. Returns whether the key was found and successfully deleted.
Seeks out and deletes an equivalent value. Returns whether the value was found and successfully deleted.
Gets the value for a key in a map.
Sets the value for a given key.
Copies values or entries from another collection into this collection, and then returns this.
Deletes every value or every value for each key. Returns the number of successful deletions.
Deletes every value equivalent to the given value from the collection.
Replaces a length of values from a starting position with the given values.
Deletes all of the values in the collection.
Finds the first equivalent value.
Finds the first equivalent value.
Finds the last equivalent value, searching from the right.
Finds the last equivalent value, searching from the right.
Returns an array of [key, class] entries where every value from the collection is placed into the same equivalence class if they return the same key through the given callback.
Returns whether any value in the collection is truthy.
Returns whether all values in the collection are truthy.
Returns one, arbitrary value from this collection, or undefined if there are none.
Returns the only value in this collection, or undefined if there is more than one value, or if there are no values in the collection.
Returns a sorted array of the values in this collection.
Returns a copy of this collection with the values in reverse order.
Returns the sum of all values in this collection.
Returns the arithmetic mean of the collection, by computing its sum and the count of values and returning the quotient.
Returns the smallest value in this collection.
Returns the largest value in this collection.
Returns an array of the respective values in this collection and in each collection provided as an argument.
Returns an array of [index, value] entries for each value in this collection, counting all values from the given index.
Assuming that this is a collection of collections, returns a new collection that contains all the values of each nested collection in order.
Returns an array of each value in this collection.
Returns an object with each property name and value corresponding to the entries in this collection.
Returns whether this collection is equivalent to the given collection.
Compares two values and returns a number having the same relative value to zero.
Creates a deep replica of this collection.
Creates a shallow clone of this collection.
Adds a listener for when values are added or removed at any position.
Unregisters a range change listener provided by addRangeChangeListener.
Informs range change listeners that values were removed then added at an index.
Adds a listener for before values are added or removed at any position.
Unregisters a range change listener provided by addBeforeRangeChangeListener or addRangeChangeListener with the beforeChange
flag.
Informs range change listeners that values will be removed then added at an index.
Adds a listener for when the value for a key changes, or when entries are added or removed.
Adds a listener for before map entries are created, deleted, or updated.
Unregisters a map change listener provided by addMapChangeListener.
Unregisters a map change listener provided by addBeforeMapChangeListener or addMapChangeListener with the beforeChange
flag.
Informs map change listeners that an entry was created, deleted, or updated.
Informs map change listeners that an entry will be created, deleted, or updated.
Adds a listener for an owned property with the given name.
Adds a listener for before a property changes.
Unregisters a property change listener provided by addOwnPropertyChangeListener.
Unregisters a property change listener provided by addBeforeOwnPropertyChangeListener or addOwnPropertyChangeListener with the beforeChange
flag.
Informs property change listeners that the value for a property name has changed.
Informs property change listeners that the value for a property name will change.
May perform internal changes necessary to dispatch property changes for a particular name.
Makes changes observable for this collection.
require("collections/shim-array");
require("collections/listen/array-changes");