OrderedSet

A type of Set that has the additional guarantee that the iteration order of values will be the order in which they were added.

Method signature

type OrderedSet<T> extends Set<T>, OrderedCollection<T>

The iteration behavior of OrderedSet is the same as native ES6 Set.

Note that OrderedSet are more expensive than non-ordered Set and may consume more memory. OrderedSet#add is amortized O(log32 N), but not stable.

Similar API with Set

OrderedSet has the exact same API as Set. The only new method is OrderedSet.isOrderedSet(maybeOrderedSet) to check if a value is an OrderedSet.

Construction

Create a new immutable OrderedSet containing the values of the provided collection-like.

Method signature

OrderedSet<T>(collection?: Iterable<T> | ArrayLike<T>): OrderedSet<T>

Note: OrderedSet is a factory function and not a class, and does not use the new keyword during construction.

Static Methods

True if the provided value is an OrderedSet.

Method signature

OrderedSet.isOrderedSet(maybeOrderedSet): boolean
;