Concrete

List

List is a dense Indexed Collection backed by a JavaScript array. List shares its peformance charactersitics with array too. get, set, push, and pop are all O(1) on lists. shift and unshift are O(n).

Map

Map is a Keyed Collection of [key, value] tuples with O(1) get and set. Its API is fully compatible with that of JavaScript Map, but the Sequins Map class delegates to a native Map for storage as opposed to extending the native Map class.

Set

Set is a Duplicated Collection of unique values with O(1) add and has. Its API is fully compatible with that of JavaScript Set, but the Sequins Set class delegates to a native Set for storage as opposed to extending the native Set class.

Sequence

IndexedSequence

An IndexedSequence is quite simply an Indexed Sequence. It represents sequential transformations against Array or List-like data as a series of chained function calls. The chain of calls will usually be terminated with toList.

KeyedSequence

A KeyedSequence is, as expected, a Keyed Sequence. It represents sequential transformations on Object or Map-like data as a series of chained function calls. Note that a KeyedSequence lacks the key-coalescing property of a Map. Duplicate keys will be eliminated when calling as(Map) which will usually be the last call in the chain.

SetSequence

A SetSequence is a Duplicated Sequence. It represents sequntial transformations on Set-like data as a series of chained function calls. Note that a SetSequence is allowed to contain duplicate values. Such duplicates will be eliminated when using as(Set) or a similar method to convert back to a concrete type after the desired transformations are made.

Seq

Seq is a helper function for creating instances of Sequence. Given any argument, Seq will make a best-effort guess as to the appropriate Sequence subtype, and will return an instance of it. The desired Sequence type can be selected by using one of the nested functions: Seq.Indexed, Seq.Keyed, or Seq.Set.

Abstract

Concrete

Concretes are a type of Collection which store their own data and have O(1) random access. It is the base class for List, Map, and Set.

Sequence

Sequence is the abstract base class for describing efficient, lazy transformations. Sequences never store their own data, instead they describe how to compute values (or keys) using a series of transforms against some source data. Sequences are immutable with regards to which transforms they apply, but as their source data is mutable applying the sequence transformations more than once may yield different results if the source data has changed. Sequence subtypes are IndexedSequence, KeyedSequence, and SetSequence.

Collection

Collection is the base type for all Sequins structures. There are two fundamental Collection types: Concrete and Sequence. The distinction is that a Concrete stores its data, while a Sequence computes it. Furthermore, all Collections have keys and values of some kind. Values are similar everywhere, but the nature of keys is determined by the Collection's subtype. Key may be explicitly declared ( Keyed subtype), the index of the item in the collection ( Indexed subtype), or just the value again as a placeholder ( Duplicated subtype).

Subtypes

Keyed

Keyed is used to describe Collections which have explicit keys and values. Callbacks for methods in classes implementing Keyed will receive (value, key) as thier first two arguments.

Indexed

Indexed is used to describe Collections of values where the collections also track the indexes of those values. Callbacks for methods in classes implementing Indexed will receive (value, index) as their first two arguments.

Duplicated

Duplicated describes collections of values where no index is desired. Instead, callbacks for methods in classes implementing Duplicated will receive (value, value) as their first two arguments, which is the source of the name.

Construction

Range()

Returns a IndexedSequence of numbers from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity. When start is equal to end, returns empty range.

Repeat()

Returns a IndexedSequence of value repeated times times. When times is not defined, returns an infinite Sequence of value.

Utility

isCollection()

True if maybeCollection is a Collection, or any of its subclasses.

isKeyed()

True if maybeKeyed is a Keyed, or any of its subclasses.

isIndexed()

True if maybeIndexed is an Indexed, or any of its subclasses.

isAssociative()

True if maybeAssociative is either a Keyed or Indexed Collection.

isSeq()

True if maybeSeq is a Sequence.

isList()

True if maybeList is a List.

isMap()

True if maybeMap is a Map.

isSet()

True if maybeSet is a Set.

get()

Returns the value within the provided collection associated with the provided key, or notSetValue if the key is not defined in the collection.

has()

Returns true if the key is defined in the provided collection.

remove()

Removes the key at value

set()

Sets key to value

keys()

Gets the keys of a Collection, Object, or Array.

values()

Gets the value of a Collection, Object, or Array.

entries()

Gets the entries of a Collection, Object, or Array.