Collections

List

An ordered list of values.

Deque

An ordered collection of values with fast random access, push, pop, shift, and unshift, but slow to splice.

Map

A map of [key, value] entries, where keys may be arbitrary values including objects.

Set

A collection of unique values.

Heap

A collection of values with the largest always on top.

Dict

A mapping from string keys to values.

SortedArray

A collection of values stored in stable stored order, backed by an array.

FastSet

The backing store for Set and FastMap.

LruSet

A set with a maximum capacity that will evict the least recently used value.

LfuSet

A set with a maximum capacity that will evict the least frequently used value.

SortedArraySet

A collection of unique values stored in sorted order, backed by a plain array.

SortedSet

A collection of values stored in sorted order using a binary tree.

FastMap

The backing store for a Map.

LfuMap

A map with a maximum capacity that will evict the least frequently used entry.

LruMap

A map with a maximum capacity that will evict the least recently used entry.

MultiMap

A map from keys to buckets, typically arrays.

SortedMap

A map with entries sorted by key.

SortedArrayMap

A map of key value pairs, sorted by key, backed by an array.

WeakMap

A map of object keys to values with good garbage collection behavior. See WeakMap.

Iterator

Produces values in order on demand.

Array

An ordered collection of values with fast random access, push(...values), and pop(), but can be slow to splice when sufficiently massive.

Object

The native JavaScript object, with some additional constructor methods shimmed.

GenericCollection

An abstract collection that implements many generic methods, reusable by most collections.

GenericOrder

An abstract collection that implements generic methods that can be used by any collection that keeps its values in a meaningful order.

GenericSet

An abstract collection that implements many generic methods, reusable by most sets.

GenericMap

An abstract collection that implements many generic methods, reusable by most maps.

PropertyChanges

A prototype that provides the interface for listening to and dispatching synchronous property change notifications.

RangeChanges

An abstract collection that provides the interface for listening to and dispatching notifications when values are removed then added at an index.

MapChanges

An abstract collection that provides the interface for listening to and dispatching notifications when the value for a key changes and when entries are added or removed.

Properties

length

The number of items in this collection.

Methods

push(...values)

Adds values to the end of a collection.

pop()

Removes a value from the end of a collection, and returns that value.

shift()

Removes a value from the beginning of a collection, and returns that value.

unshift(...values)

Adds values to the beginning of a collection.

peek()

Returns the value at the beginning of a collection, the value that would be returned by shift().

poke(value)

Replaces the value at the beginning of a collection, the value that would be returned by shift().

peekBack()

Returns the value at the end of a collection, the value that would be returned by pop().

pokeBack(value)

Replaces the value at the end of a collection, the value that would be returned by pop().

union(values)

Returns the set of values including all values from both of these sets.

intersection(values)

Returns the set of values that are in both of these sets.

difference(values)

Returns the set of values that are in this set, excluding the values that are also in the other set.

symmetricDifference(values)

Returns the set of values that are only in one of these sets.

has(value)

Whether an equivalent value exists in this collection.

has(value, equals?)

Returns whether an equivalent value exists in this collection.

get(value)

Retrieves the equivalent value from the collection.

get(value, equals?)

Retrieves the equivalent value from this collection.

add(value)

Adds a value to a collection.

delete(value)

Deletes the first equivalent value. Returns whether the key was found and successfully deleted.

delete(value, equals?)

Seeks out and deletes an equivalent value. Returns whether the value was found and successfully deleted.

remove(value)

An alias for delete(value) on sets that increases the overlap with the W3C DOMTokenList interface, implemented by classList.

contains(value)

An alias for has(value) on sets that increases the overlap with the W3C DOMTokenList interface, implemented by classList.

toggle(value)

Toggles the existence of a value in a set.

has(key)

Returns whether an entry with the given key exists in a Map.

get(key|index, default?)

Gets the value for a key in a map.

set(key, value)

Sets the value for a given key.

add(value, key)

Adds a value for a given key to a map.

delete(key)

Deletes the value for a given key. Returns whether the key was found and successfully deleted.

keys()

Returns an array of the keys of this map.

values()

Returns an array of the values of this map.

entries()

Returns an array of all [key, value] entries for this map.

addEach(values|map)

Copies values or entries from another collection into this collection, and then returns this.

deleteEach(values|keys, equals?)

Deletes every value or every value for each key. Returns the number of successful deletions.

deleteAll(value, equals?)

Deletes every value equivalent to the given value from the collection.

slice(start?, end?)

Returns an array of the values contained in the half-open interval [start, end), that is, including the start and excluding the end.

splice(start, length, ...values)

Replaces a length of values from a starting position with the given variadic values, and returns the values that were replaced as an array.

swap(start, length, values?)

Replaces a length of values from a starting position with the given values.

clear()

Deletes all of the values in the collection.

indexOf(value)

Returns the position of a value, or -1 if the value is not found.

lastIndexOf(value)

Returns the last position of a value, or -1 if the value is not found.

indexOf(value, start?)

Returns the position of a value, or -1 if the value is not found.

lastIndexOf(value, start?)

Returns the last position of a value, or -1 if the value is not found.

find(callback, thisp?)

(not implemented) Finds the first value within a collection that passes a test.

findLast(callback, thisp?)

(not implemented) Finds the last value within a collection that passes a test, searching from the right.

findIndex(callback, thisp?)

(not implemented) Finds the first value within a collection that passes a test. Finds the first index within a collection that passes a test.

findLastIndex(callback, thisp?)

(not implemented) Finds the last index within a collection that passes a test, searching from the right.

find|findValue(value, equals?, start?)

Finds the first equivalent value.

findLast|findLastValue(value, equals?, start?)

Finds the last equivalent value, searching from the right.

findLeast()

Finds the smallest value, returning the node at which it was found, or undefined.

findLeastGreaterThan(value)

Finds the smallest value greater than the given value, returning the node at which it was found, or undefined.

findLeastGreaterThanOrEqual(value)

Finds the smallest value greater than or equal to the given value, returning the node at which it was found, or undefined.

findGreatest()

Finds the largest value, returning the node at which it was found, or undefined.

findLGreatestLessThan(value)

Finds the largest value less than the given value, returning the node at which it was found, or undefined.

findGreatestLessThanOrEqual(value)

Finds the largest value less than or equal to the given value, returning the node at which it was found, or undefined.

mapIterator(callback, thisp?)

Returns an iterator for the respective return values of a callback for each value from this iteration.

filterIterator(callback, thisp?)

Returns an iterator for all values from this iterator that pass a test.

dropWhile(callback, thisp?)

Returns an iterator that will begin with the first value from this iteration that passes a test.

takeWhile(callback, thisp?)

Returns an iterator that will produce every value from this iteration until an entry fails a test.

zipIterator(...iterables)

Returns an iterator that will produce an array of values with the value at the same index of this iterator and each given iterable.

enumerateIterator(start?)

Creates an iterator that will produce [index, value] for each value in this iterator, on demand.

iterate()

Iterates every value in this collection.

iterate(start?, end?)

Iterates from start to end within a collection.

iterate|iterator()

Iterates every value in this collection.

forEach(callback, thisp?)

Calls the callback for each entry in the collection.

map(callback, thisp?)

Returns an array of the respective return values of a callback for each entry in this collection.

filter(callback, thisp?)

Returns an array with each value from this collection that passes the given test.

reduce(callback, basis)

Aggregates every value in this collection with the result collected up to that index.

reduceRight(callback, basis)

Aggregates every value in this collection, from right to left.

group(callback, thisp?, equals?)

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.

some(callback, thisp?)

Returns whether any entry in this collection passes a given test.

every(callback, thisp?)

Returns whether every entry in this collection passes a given test.

any()

Returns whether any value in the collection is truthy.

all()

Returns whether all values in the collection are truthy.

one()

Returns one, arbitrary value from this collection, or undefined if there are none.

only()

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.

sort(compare?)

Sorts a collection in place.

sorted(compare?)

Returns a sorted array of the values in this collection.

reverse()

Reverses the order of this collection in place.

reversed()

Returns a copy of this collection with the values in reverse order.

join(delimiter?)

Returns a string of all the values in the collection delimited by the given string.

split(delimiter)

Returns an array of all the non-overlapping strings between the given delimiter. The delimiter may be either a string or a regular expression.

sum(zero?)

Returns the sum of all values in this collection.

average()

Returns the arithmetic mean of the collection, by computing its sum and the count of values and returning the quotient.

min()

Returns the smallest value in this collection.

max()

Returns the largest value in this collection.

zip(...iterables)

Returns an array of the respective values in this collection and in each collection provided as an argument.

unzip(collections)

Given a collection of collections, returns the respective an array containing the respective values from each inner collection. unzip is equivalent to a matrix transpose.

enumerate(start?)

Returns an array of [index, value] entries for each value in this collection, counting all values from the given index.

concat(...iterables)

Returns a new collection of the same type containing all the values of itself and the values of any number of other iterable collections in order.

flatten()

Assuming that this is a collection of collections, returns a new collection that contains all the values of each nested collection in order.

toArray()

Returns an array of each value in this collection.

toObject()

Returns an object with each property name and value corresponding to the entries in this collection.

toJSON()

Used by JSON.stringify to create a JSON representation of the collection.

equals(value, equals?)

Returns whether this collection is equivalent to the given collection.

compare(value, compare?)

Compares two values and returns a number having the same relative value to zero.

hash(value)

Consistently returns the same string for the same object.

clone(depth?, memo?)

Creates a deep replica of this collection.

constructClone(values?)

Creates a shallow clone of this collection.

contentCompare(left, right)

The compare function used by this collection to determine how to order its own values.

contentEquals(left, right)

The equals function used to check whether values in this collection are equivalent.

contentHash(value)

The hash function used by this collection to hash its own values.

ensureCapacity(capacity)

An internal method of Deque that will grow the backing store if necessary.

grow(capacity)

An implementation detail of a Deque that will increase the size of its backing store.

scan(index, default)

An internal utility of List coercing indexes to nodes.

splay(value)

Rotates a splay tree until the value is at the root, or would be between the root and one of its children.

splayIndex(index)

Rotates the tree until the node at a given index floats to the top.

sortedSetLog(...)

Writes a tree describing the internal state of the sorted set splay tree.

addRangeChangeListener(listener, token?, beforeChange?)

Adds a listener for when values are added or removed at any position.

removeRangeChangeListener(listener, token?, beforeChange?)

Unregisters a range change listener provided by addRangeChangeListener.

dispatchRangeChange(plus, minus, index, beforeChange?)

Informs range change listeners that values were removed then added at an index.

addBeforeRangeChangeListener(listener, token?)

Adds a listener for before values are added or removed at any position.

removeBeforeRangeChangeListener(listener, token?)

Unregisters a range change listener provided by addBeforeRangeChangeListener or addRangeChangeListener with the beforeChange flag.

dispatchBeforeRangeChange(plus, minus, index)

Informs range change listeners that values will be removed then added at an index.

addMapChangeListener(listener, token?, beforeChange?)

Adds a listener for when the value for a key changes, or when entries are added or removed.

addBeforeMapChangeListener(listener, token?)

Adds a listener for before map entries are created, deleted, or updated.

removeMapChangeListener(listener, token?, beforeChange?)

Unregisters a map change listener provided by addMapChangeListener.

removeBeforeMapChangeListener(listener, token?)

Unregisters a map change listener provided by addBeforeMapChangeListener or addMapChangeListener with the beforeChange flag.

dispatchMapChange(key, value, beforeChange?)

Informs map change listeners that an entry was created, deleted, or updated.

dispatchBeforeMapChange(key, value)

Informs map change listeners that an entry will be created, deleted, or updated.

addOwnPropertyChangeListener(key, listener, beforeChange?)

Adds a listener for an owned property with the given name.

addBeforeOwnPropertyChangeListener(name, listener)

Adds a listener for before a property changes.

removeOwnPropertyChangeListener(name, listener, beforeChange?)

Unregisters a property change listener provided by addOwnPropertyChangeListener.

removeBeforeOwnPropertyChangeListener(key, listener)

Unregisters a property change listener provided by addBeforeOwnPropertyChangeListener or addOwnPropertyChangeListener with the beforeChange flag.

dispatchOwnPropertyChange(key, value, beforeChange?)

Informs property change listeners that the value for a property name has changed.

dispatchBeforeOwnPropertyChange(key, value)

Informs property change listeners that the value for a property name will change.

makePropertyObservable(name)

May perform internal changes necessary to dispatch property changes for a particular name.

makeObservable()

Makes changes observable for this collection.