Immutable data encourages pure functions (data-in, data-out) and lends itself to much simpler application development and enabling techniques from functional programming such as lazy evaluation.

While designed to bring these powerful functional concepts to JavaScript, it presents an Object-Oriented API familiar to Javascript engineers and closely mirroring that of Array, Map, and Set. It is easy and efficient to convert to and from plain Javascript types.

Note: all examples are presented in ES6. To run in all browsers, they need to be translated to ES3. For example:

// ES6 foo.map(x => x * x); // ES3 foo.map(function (x) { return x * x; });

Deeply converts plain JS objects and arrays to Immutable Maps and Lists.

fromJS(json: any, reviver?: (k: any, v: Iterable<any, any>) => any): any

If a `reviver`

is optionally provided, it will be called with every collection as a Seq (beginning with the most nested collections and proceeding to the top-level collection itself), along with the key refering to each collection and the parent JS object provided as `this`

. For the top level, object, the key will be `""`

. This `reviver`

is expected to return a new Immutable Iterable, allowing for custom conversions from deep JS objects.

This example converts JSON to List and OrderedMap:

Immutable.fromJS({a: {b: [10, 20, 30]}, c: 40}, function (key, value) { var isIndexed = Immutable.Iterable.isIndexed(value); return isIndexed ? value.toList() : value.toOrderedMap(); }); // true, "b", {b: [10, 20, 30]} // false, "a", {a: {b: [10, 20, 30]}, c: 40} // false, "", {"": {a: {b: [10, 20, 30]}, c: 40}}

If `reviver`

is not provided, the default behavior will convert Arrays into Lists and Objects into Maps.

`reviver`

acts similarly to the same parameter in `JSON.parse`

.

`Immutable.fromJS`

is conservative in its conversion. It will only convert arrays which pass `Array.isArray`

to Lists, and only raw objects (no custom prototype) to Map.

Keep in mind, when using JS objects to construct Immutable Maps, that JavaScript Object properties are always strings, even if written in a quote-less shorthand, while Immutable Maps accept keys of any type.

var obj = { 1: "one" }; Object.keys(obj); // [ "1" ] obj["1"]; // "one" obj[1]; // "one" var map = Map(obj); map.get("1"); // "one" map.get(1); // undefined

Property access for JavaScript Objects first converts the key to a string, but since Immutable Map keys can be of any type the argument to `get()`

is not altered.

"Using the reviver parameter"

Value equality check with semantics similar to `Object.is`

, but treats Immutable `Iterable`

s as values, equal if the second `Iterable`

includes equivalent values.

is(first: any, second: any): boolean

It's used throughout Immutable when checking for equality, including `Map`

key equality and `Set`

membership.

var map1 = Immutable.Map({a:1, b:1, c:1}); var map2 = Immutable.Map({a:1, b:1, c:1}); assert(map1 !== map2); assert(Object.is(map1, map2) === false); assert(Immutable.is(map1, map2) === true);

Note: Unlike `Object.is`

, `Immutable.is`

assumes `0`

and `-0`

are the same value, matching the behavior of ES6 Map key equality.

Lists are ordered indexed dense collections, much like a JavaScript Array.

class List<T> extends Collection.Indexed<T>

Lists are immutable and fully persistent with O(log32 N) gets and sets, and O(1) push and pop.

Lists implement Deque, with efficient addition and removal from both the end (`push`

, `pop`

) and beginning (`unshift`

, `shift`

).

Unlike a JavaScript Array, there is no distinction between an "unset" index and an index set to `undefined`

. `List#forEach`

visits all indices from 0 to size, regardless of whether they were explicitly defined.

Create a new immutable List containing the values of the provided iterable-like.

List<T>(): List<T> List<T>(iter: Iterable.Indexed<T>): List<T> List<T>(iter: Iterable.Set<T>): List<T> List<K, V>(iter: Iterable.Keyed<K, V>): List<any> List<T>(array: Array<T>): List<T> List<T>(iterator: Iterator<T>): List<T> List<T>(iterable: Object): List<T>

True if the provided value is a List

List.isList(maybeList: any): boolean

Creates a new List containing `values`

.

List.of<T>(...values: T[]): List<T>

size: number

`Collection#size`

Returns a new List which includes `value`

at `index`

. If `index`

already exists in this List, it will be replaced.

set(index: number, value: T): List<T>

`index`

may be a negative number, which indexes back from the end of the List. `v.set(-1, "value")`

sets the last item in the List.

If `index`

larger than `size`

, the returned List's `size`

will be large enough to include the `index`

.

Returns a new List which excludes this `index`

and with a size 1 less than this List. Values at indices above `index`

are shifted down by 1 to fill the position.

delete(index: number): List<T>

`remove()`

This is synonymous with `list.splice(index, 1)`

.

`index`

may be a negative number, which indexes back from the end of the List. `v.delete(-1)`

deletes the last item in the List.

Note: `delete`

cannot be safely used in IE8

Returns a new List with `value`

at `index`

with a size 1 more than this List. Values at indices above `index`

are shifted over by 1.

insert(index: number, value: T): List<T>

This is synonymous with `list.splice(index, 0, value)

Returns a new List with 0 size and no values.

clear(): List<T>

Returns a new List with the provided `values`

appended, starting at this List's `size`

.

push(...values: T[]): List<T>

Returns a new List with a size ones less than this List, excluding the last index in this List.

pop(): List<T>

Note: this differs from `Array#pop`

because it returns a new List rather than the removed value. Use `last()`

to get the last value in this List.

Returns a new List with the provided `values`

prepended, shifting other values ahead to higher indices.

unshift(...values: T[]): List<T>

Returns a new List with a size ones less than this List, excluding the first index in this List, shifting all other values to a lower index.

shift(): List<T>

Note: this differs from `Array#shift`

because it returns a new List rather than the removed value. Use `first()`

to get the first value in this List.

Returns a new List with an updated value at `index`

with the return value of calling `updater`

with the existing value, or `notSetValue`

if `index`

was not set. If called with a single argument, `updater`

is called with the List itself.

update(updater: (value: List<T>) => List<T>): List<T> update(index: number, updater: (value: T) => T): List<T> update(index: number, notSetValue: T, updater: (value: T) => T): List<T>

`index`

may be a negative number, which indexes back from the end of the List. `v.update(-1)`

updates the last item in the List.

merge(...iterables: Iterable.Indexed<T>[]): List<T> merge(...iterables: Array<T>[]): List<T>

mergeWith(merger: (previous?: T, next?: T, key?: number) => T,...iterables: Iterable.Indexed<T>[]): List<T> mergeWith(merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]): List<T>

mergeDeep(...iterables: Iterable.Indexed<T>[]): List<T> mergeDeep(...iterables: Array<T>[]): List<T>

mergeDeepWith(merger: (previous?: T, next?: T, key?: number) => T,...iterables: Iterable.Indexed<T>[]): List<T> mergeDeepWith(merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]): List<T>

Returns a new List with size `size`

. If `size`

is less than this List's size, the new List will exclude values at the higher indices. If `size`

is greater than this List's size, the new List will have undefined values for the newly available indices.

setSize(size: number): List<T>

When building a new List and the final size is known up front, `setSize`

used in conjunction with `withMutations`

may result in the more performant construction.

Returns a new List having set `value`

at this `keyPath`

. If any keys in `keyPath`

do not exist, a new immutable Map will be created at that key.

setIn(keyPath: Array<any>, value: any): List<T> setIn(keyPath: Iterable<any, any>, value: any): List<T>

Index numbers are used as keys to determine the path to follow in the List.

Returns a new List having removed the value at this `keyPath`

. If any keys in `keyPath`

do not exist, no change will occur.

deleteIn(keyPath: Array<any>): List<T> deleteIn(keyPath: Iterable<any, any>): List<T>

`removeIn()`

updateIn(keyPath: Array<any>, updater: (value: any) => any): List<T> updateIn(keyPath: Array<any>,notSetValue: any,updater: (value: any) => any): List<T> updateIn(keyPath: Iterable<any, any>, updater: (value: any) => any): List<T> updateIn(keyPath: Iterable<any, any>,notSetValue: any,updater: (value: any) => any): List<T>

mergeIn(keyPath: Iterable<any, any>,...iterables: Iterable.Indexed<T>[]): List<T> mergeIn(keyPath: Array<any>, ...iterables: Iterable.Indexed<T>[]): List<T> mergeIn(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>

mergeDeepIn(keyPath: Iterable<any, any>,...iterables: Iterable.Indexed<T>[]): List<T> mergeDeepIn(keyPath: Array<any>, ...iterables: Iterable.Indexed<T>[]): List<T> mergeDeepIn(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `set`

, `push`

, `pop`

, `shift`

, `unshift`

and `merge`

may be used mutatively.

withMutations(mutator: (mutable: List<T>) => any): List<T>

asMutable(): List<T>

asImmutable(): List<T>

Returns Seq.Indexed.

toSeq(): Seq.Indexed<T>

`Collection.Indexed#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<number, T>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

var indexedSeq = Immutable.Seq.of('A', 'B', 'C'); indexedSeq.filter(v => v === 'B').toString() // Seq [ 'B' ] var keyedSeq = indexedSeq.toKeyedSeq(); keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<T>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<T>

`Iterable#toSetSeq`

If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

fromEntrySeq(): Seq.Keyed<any, any>

`Iterable.Indexed#fromEntrySeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<number, T>): boolean

`Iterable#equals`

Note: This is equivalent to `Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

The `hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

var a = List.of(1, 2, 3); var b = List.of(1, 2, 3); assert(a !== b); // different instances var set = Set.of(a); assert(set.has(b) === true);

If two values have the same `hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

get(key: number, notSetValue?: T): T

`Iterable#get`

Note: it is possible a key may be associated with an `undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: number): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: T): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): T

`Iterable#first`

The last value in the Iterable.

last(): T

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

getIn(searchKeyPath: Array<any>, notSetValue?: any): any getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any

`Iterable#getIn`

True if the result of following a path of keys or indices through nested Iterables results in a set value.

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<T>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<number, T>

`Iterable#toMap`

Note: This is equivalent to `Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<number, T>

`Iterable#toOrderedMap`

Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<T>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<T>

`Iterable#toOrderedSet`

Note: This is equivalent to `OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<T>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<T>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<number>

`Iterable#keys`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<T>

`Iterable#values`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<number>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<T>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: T, key?: number, iter?: Iterable<number, T>) => M,context?: any): Iterable<number, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns true.

filter(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns false.

filterNot(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<number, T>

`Iterable#reverse`

Returns a new Iterable of the same type which includes the same entries, stably sorted by using a `comparator`

.

sort(comparator?: (valueA: T, valueB: T) => number): Iterable<number, T>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

When sorting collections which have no defined order, their ordered equivalents will be returned. e.g. `map.sort()`

returns OrderedMap.

Like `sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<number, T>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: T, key?: number, iter?: Iterable<number, T>) => G,context?: any): Seq.Keyed<G, Iterable<number, T>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: T, key?: number, iter?: Iterable<number, T>) => any,context?: any): number

`Iterable#forEach`

Unlike `Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

slice(begin?: number, end?: number): Iterable<number, T>

`Iterable#slice`

If begin is negative, it is offset from the end of the Iterable. e.g. `slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

If end is negative, it is offset from the end of the Iterable. e.g. `slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<number, T>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<number, T>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<number, T>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<number, T>

`Iterable#skipLast`

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns false.

skipWhile(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns true.

skipUntil(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<number, T>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<number, T>

`Iterable#takeLast`

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns true.

takeWhile(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns false.

takeUntil(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

concat(...valuesOrIterables: any[]): Iterable<number, T>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

Will deeply flatten the Iterable by default, returning an Iterable of the same type, but a `depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: T,key?: number,iter?: Iterable<number, T>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: T, key?: number, iter?: Iterable<number, T>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

Returns an Iterable of the same type with `separator`

between each item in this Iterable.

interpose(separator: T): Iterable.Indexed<T>

`Iterable.Indexed#interpose`

Returns an Iterable of the same type with the provided `iterables`

interleaved into this iterable.

interleave(...iterables: Array<Iterable<any, T>>): Iterable.Indexed<T>

`Iterable.Indexed#interleave`

The resulting Iterable includes the first item from each, then the second from each, etc.

I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C')) // Seq [ 1, 'A', 2, 'B', 3, 'C' ]

The shortest Iterable stops interleave.

I.Seq.of(1,2,3).interleave( I.Seq.of('A','B'), I.Seq.of('X','Y','Z') ) // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]

Splice returns a new indexed Iterable by replacing a region of this Iterable with new values. If values are not provided, it only skips the region to be removed.

splice(index: number, removeNum: number, ...values: any[]): Iterable.Indexed<T>

`Iterable.Indexed#splice`

`index`

may be a negative number, which indexes back from the end of the Iterable. `s.splice(-2)`

splices after the second to last item.

Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's') // Seq ['a', 'q', 'r', 's', 'd']

Returns an Iterable of the same type "zipped" with the provided iterables.

zip(...iterables: Array<Iterable<any, any>>): Iterable.Indexed<any>

`Iterable.Indexed#zip`

Like `zipWith`

, but using the default `zipper`

: creating an `Array`

.

var a = Seq.of(1, 2, 3); var b = Seq.of(4, 5, 6); var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

Returns an Iterable of the same type "zipped" with the provided iterables by using a custom `zipper`

function.

zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z,otherIterable: Iterable<any, U>): Iterable.Indexed<Z> zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z,otherIterable: Iterable<any, U>,thirdIterable: Iterable<any, V>): Iterable.Indexed<Z> zipWith<Z>(zipper: (...any: Array<any>) => Z,...iterables: Array<Iterable<any, any>>): Iterable.Indexed<Z>

`Iterable.Indexed#zipWith`

var a = Seq.of(1, 2, 3); var b = Seq.of(4, 5, 6); var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]

Reduces the Iterable to a value by calling the `reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R,value?: T,key?: number,iter?: Iterable<number, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R,value?: T,key?: number,iter?: Iterable<number, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): boolean

`Iterable#some`

Joins values together as a string, inserting a separator between each. The default separator is `","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

For some lazy `Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): number

`Iterable#count`

Regardless of if this Iterable can describe its size lazily (some Seqs cannot), this method will always return the correct size. E.g. it evaluates a lazy `Seq`

if necessary.

If `predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: T, key?: number, iter?: Iterable<number, T>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: T,key?: number,iter?: Iterable.Keyed<number, T>) => boolean,context?: any): number

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: T,key?: number,iter?: Iterable.Keyed<number, T>) => boolean,context?: any): number

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: T): number

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: T): number

`Iterable#lastKeyOf`

Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

max(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#max`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

min(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#min`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

indexOf(searchValue: T): number

`Iterable.Indexed#indexOf`

Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

lastIndexOf(searchValue: T): number

`Iterable.Indexed#lastIndexOf`

Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

findIndex(predicate: (value?: T, index?: number, iter?: Iterable.Indexed<T>) => boolean,context?: any): number

`Iterable.Indexed#findIndex`

Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

findLastIndex(predicate: (value?: T, index?: number, iter?: Iterable.Indexed<T>) => boolean,context?: any): number

`Iterable.Indexed#findLastIndex`

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, T>): boolean isSubset(iter: Array<T>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, T>): boolean isSuperset(iter: Array<T>): boolean

`Iterable#isSuperset`

Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with `O(log32 N)`

gets and `O(log32 N)`

persistent sets.

class Map<K, V> extends Collection.Keyed<K, V>

Iteration order of a Map is undefined, however is stable. Multiple iterations of the same Map will iterate in the same order.

Map's keys can be of any type, and use `Immutable.is`

to determine key equality. This allows the use of any value (including NaN) as a key.

Because `Immutable.is`

returns equality based on value semantics, and Immutable collections are treated as values, any Immutable collection may be used as a key.

Map().set(List.of(1), 'listofone').get(List.of(1)); // 'listofone'

Any JavaScript object may be used as a key, however strict identity is used to evaluate key equality. Two similar looking objects will represent two different keys.

Implemented by a hash-array mapped trie.

Creates a new Immutable Map.

Map<K, V>(): Map<K, V> Map<K, V>(iter: Iterable.Keyed<K, V>): Map<K, V> Map<K, V>(iter: Iterable<any, Array<any>>): Map<K, V> Map<K, V>(array: Array<Array<any>>): Map<K, V> Map<V>(obj: {[key: string]: V}): Map<string, V> Map<K, V>(iterator: Iterator<Array<any>>): Map<K, V> Map<K, V>(iterable: Object): Map<K, V>

Created with the same key value pairs as the provided Iterable.Keyed or JavaScript Object or expects an Iterable of [K, V] tuple entries.

var newMap = Map({key: "value"}); var newMap = Map([["key", "value"]]);

Keep in mind, when using JS objects to construct Immutable Maps, that JavaScript Object properties are always strings, even if written in a quote-less shorthand, while Immutable Maps accept keys of any type.

var obj = { 1: "one" }; Object.keys(obj); // [ "1" ] obj["1"]; // "one" obj[1]; // "one" var map = Map(obj); map.get("1"); // "one" map.get(1); // undefined

Property access for JavaScript Objects first converts the key to a string, but since Immutable Map keys can be of any type the argument to `get()`

is not altered.

True if the provided value is a Map

Map.isMap(maybeMap: any): boolean

Creates a new Map from alternating keys and values

Map.of(...keyValues: any[]): Map<any, any>

size: number

`Collection#size`

Returns a new Map also containing the new key, value pair. If an equivalent key already exists in this Map, it will be replaced.

set(key: K, value: V): Map<K, V>

Returns a new Map which excludes this `key`

.

delete(key: K): Map<K, V>

`remove()`

Note: `delete`

cannot be safely used in IE8, but is provided to mirror the ES6 collection API.

Returns a new Map containing no keys or values.

clear(): Map<K, V>

Returns a new Map having updated the value at this `key`

with the return value of calling `updater`

with the existing value, or `notSetValue`

if the key was not set. If called with only a single argument, `updater`

is called with the Map itself.

update(updater: (value: Map<K, V>) => Map<K, V>): Map<K, V> update(key: K, updater: (value: V) => V): Map<K, V> update(key: K, notSetValue: V, updater: (value: V) => V): Map<K, V>

Equivalent to: `map.set(key, updater(map.get(key, notSetValue)))`

.

Returns a new Map resulting from merging the provided Iterables (or JS objects) into this Map. In other words, this takes each entry of each iterable and sets it on this Map.

merge(...iterables: Iterable<K, V>[]): Map<K, V> merge(...iterables: {[key: string]: V}[]): Map<string, V>

If any of the values provided to `merge`

are not Iterable (would return false for `Immutable.Iterable.isIterable`

) then they are deeply converted via `Immutable.fromJS`

before being merged. However, if the value is an Iterable but includes non-iterable JS objects or arrays, those nested values will be preserved.

var x = Immutable.Map({a: 10, b: 20, c: 30}); var y = Immutable.Map({b: 40, a: 50, d: 60}); x.merge(y) // { a: 50, b: 40, c: 30, d: 60 } y.merge(x) // { b: 20, a: 10, d: 60, c: 30 }

Like `merge()`

, `mergeWith()`

returns a new Map resulting from merging the provided Iterables (or JS objects) into this Map, but uses the `merger`

function for dealing with conflicts.

mergeWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: Iterable<K, V>[]): Map<K, V> mergeWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: {[key: string]: V}[]): Map<string, V>

var x = Immutable.Map({a: 10, b: 20, c: 30}); var y = Immutable.Map({b: 40, a: 50, d: 60}); x.mergeWith((prev, next) => prev / next, y) // { a: 0.2, b: 0.5, c: 30, d: 60 } y.mergeWith((prev, next) => prev / next, x) // { b: 2, a: 5, d: 60, c: 30 }

Like `merge()`

, but when two Iterables conflict, it merges them as well, recursing deeply through the nested data.

mergeDeep(...iterables: Iterable<K, V>[]): Map<K, V> mergeDeep(...iterables: {[key: string]: V}[]): Map<string, V>

var x = Immutable.fromJS({a: { x: 10, y: 10 }, b: { x: 20, y: 50 } }); var y = Immutable.fromJS({a: { x: 2 }, b: { y: 5 }, c: { z: 3 } }); x.mergeDeep(y) // {a: { x: 2, y: 10 }, b: { x: 20, y: 5 }, c: { z: 3 } }

Like `mergeDeep()`

, but when two non-Iterables conflict, it uses the `merger`

function to determine the resulting value.

mergeDeepWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: {[key: string]: V}[]): Map<string, V>

var x = Immutable.fromJS({a: { x: 10, y: 10 }, b: { x: 20, y: 50 } }); var y = Immutable.fromJS({a: { x: 2 }, b: { y: 5 }, c: { z: 3 } }); x.mergeDeepWith((prev, next) => prev / next, y) // {a: { x: 5, y: 10 }, b: { x: 20, y: 10 }, c: { z: 3 } }

Returns a new Map having set `value`

at this `keyPath`

. If any keys in `keyPath`

do not exist, a new immutable Map will be created at that key.

setIn(keyPath: Array<any>, value: any): Map<K, V> setIn(KeyPath: Iterable<any, any>, value: any): Map<K, V>

Returns a new Map having removed the value at this `keyPath`

. If any keys in `keyPath`

do not exist, no change will occur.

deleteIn(keyPath: Array<any>): Map<K, V> deleteIn(keyPath: Iterable<any, any>): Map<K, V>

`removeIn()`

Returns a new Map having applied the `updater`

to the entry found at the keyPath.

updateIn(keyPath: Array<any>, updater: (value: any) => any): Map<K, V> updateIn(keyPath: Array<any>,notSetValue: any,updater: (value: any) => any): Map<K, V> updateIn(keyPath: Iterable<any, any>, updater: (value: any) => any): Map<K, V> updateIn(keyPath: Iterable<any, any>,notSetValue: any,updater: (value: any) => any): Map<K, V>

If any keys in `keyPath`

do not exist, new Immutable `Map`

s will be created at those keys. If the `keyPath`

does not already contain a value, the `updater`

function will be called with `notSetValue`

, if provided, otherwise `undefined`

.

var data = Immutable.fromJS({ a: { b: { c: 10 } } }); data = data.updateIn(['a', 'b', 'c'], val => val * 2); // { a: { b: { c: 20 } } }

If the `updater`

function returns the same value it was called with, then no change will occur. This is still true if `notSetValue`

is provided.

var data1 = Immutable.fromJS({ a: { b: { c: 10 } } }); data2 = data1.updateIn(['x', 'y', 'z'], 100, val => val); assert(data2 === data1);

A combination of `updateIn`

and `merge`

, returning a new Map, but performing the merge at a point arrived at by following the keyPath. In other words, these two lines are equivalent:

mergeIn(keyPath: Iterable<any, any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeIn(keyPath: Array<any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeIn(keyPath: Array<any>, ...iterables: {[key: string]: V}[]): Map<string, V>

x.updateIn(['a', 'b', 'c'], abc => abc.merge(y)); x.mergeIn(['a', 'b', 'c'], y);

A combination of `updateIn`

and `mergeDeep`

, returning a new Map, but performing the deep merge at a point arrived at by following the keyPath. In other words, these two lines are equivalent:

mergeDeepIn(keyPath: Iterable<any, any>,...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepIn(keyPath: Array<any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepIn(keyPath: Array<any>,...iterables: {[key: string]: V}[]): Map<string, V>

x.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)); x.mergeDeepIn(['a', 'b', 'c'], y);

Every time you call one of the above functions, a new immutable Map is created. If a pure function calls a number of these to produce a final return value, then a penalty on performance and memory has been paid by creating all of the intermediate immutable Maps.

withMutations(mutator: (mutable: Map<K, V>) => any): Map<K, V>

If you need to apply a series of mutations to produce a new immutable Map, `withMutations()`

creates a temporary mutable copy of the Map which can apply mutations in a highly performant manner. In fact, this is exactly how complex mutations like `merge`

are done.

As an example, this results in the creation of 2, not 4, new Maps:

var map1 = Immutable.Map(); var map2 = map1.withMutations(map => { map.set('a', 1).set('b', 2).set('c', 3); }); assert(map1.size === 0); assert(map2.size === 3);

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `set`

and `merge`

may be used mutatively.

Another way to avoid creation of intermediate Immutable maps is to create a mutable copy of this collection. Mutable copies *always* return `this`

, and thus shouldn't be used for equality. Your function should never return a mutable copy of a collection, only use it internally to create a new collection. If possible, use `withMutations`

as it provides an easier to use API.

asMutable(): Map<K, V>

Note: if the collection is already mutable, `asMutable`

returns itself.

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `set`

and `merge`

may be used mutatively.

The yin to `asMutable`

's yang. Because it applies to mutable collections, this operation is *mutable* and returns itself. Once performed, the mutable copy has become immutable and can be safely returned from a function.

asImmutable(): Map<K, V>

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Collection.Keyed#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

var indexedSeq = Immutable.Seq.of('A', 'B', 'C'); indexedSeq.filter(v => v === 'B').toString() // Seq [ 'B' ] var keyedSeq = indexedSeq.toKeyedSeq(); keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

Note: This is equivalent to `Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

The `hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

var a = List.of(1, 2, 3); var b = List.of(1, 2, 3); assert(a !== b); // different instances var set = Set.of(a); assert(set.has(b) === true);

If two values have the same `hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

get(key: K, notSetValue?: V): V

`Iterable#get`

Note: it is possible a key may be associated with an `undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

getIn(searchKeyPath: Array<any>, notSetValue?: any): any getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any

`Iterable#getIn`

True if the result of following a path of keys or indices through nested Iterables results in a set value.

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

Note: This is equivalent to `Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

Note: This is equivalent to `OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns true.

filter(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns false.

filterNot(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

Returns a new Iterable of the same type which includes the same entries, stably sorted by using a `comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

When sorting collections which have no defined order, their ordered equivalents will be returned. e.g. `map.sort()`

returns OrderedMap.

Like `sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<K, V>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Seq.Keyed<G, Iterable<K, V>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

Unlike `Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

If begin is negative, it is offset from the end of the Iterable. e.g. `slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

If end is negative, it is offset from the end of the Iterable. e.g. `slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns false.

skipWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns true.

skipUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns true.

takeWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns false.

takeUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

Will deeply flatten the Iterable by default, returning an Iterable of the same type, but a `depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

Reduces the Iterable to a value by calling the `reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

Joins values together as a string, inserting a separator between each. The default separator is `","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

For some lazy `Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): number

`Iterable#count`

Regardless of if this Iterable can describe its size lazily (some Seqs cannot), this method will always return the correct size. E.g. it evaluates a lazy `Seq`

if necessary.

If `predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

mapKeys<M>(mapper: (key?: K, value?: V, iter?: Iterable.Keyed<K, V>) => M,context?: any): Iterable.Keyed<M, V>

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a `mapper`

function.

mapEntries<KM, VM>(mapper: (entry?: Array<any>,index?: number,iter?: Iterable.Keyed<K, V>) => Array<any>,context?: any): Iterable.Keyed<KM, VM>

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

A type of Map that has the additional guarantee that the iteration order of entries will be the order in which they were set().

class OrderedMap<K, V> extends Map<K, V>

The iteration behavior of OrderedMap is the same as native ES6 Map and JavaScript Object.

Note that `OrderedMap`

are more expensive than non-ordered `Map`

and may consume more memory. `OrderedMap#set`

is amortized O(log32 N), but not stable.

Creates a new Immutable OrderedMap.

OrderedMap<K, V>(): OrderedMap<K, V> OrderedMap<K, V>(iter: Iterable.Keyed<K, V>): OrderedMap<K, V> OrderedMap<K, V>(iter: Iterable<any, Array<any>>): OrderedMap<K, V> OrderedMap<K, V>(array: Array<Array<any>>): OrderedMap<K, V> OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V> OrderedMap<K, V>(iterator: Iterator<Array<any>>): OrderedMap<K, V> OrderedMap<K, V>(iterable: Object): OrderedMap<K, V>

Created with the same key value pairs as the provided Iterable.Keyed or JavaScript Object or expects an Iterable of [K, V] tuple entries.

The iteration order of key-value pairs provided to this constructor will be preserved in the OrderedMap.

var newOrderedMap = OrderedMap({key: "value"}); var newOrderedMap = OrderedMap([["key", "value"]]);

True if the provided value is an OrderedMap.

OrderedMap.isOrderedMap(maybeOrderedMap: any): boolean

size: number

`Collection#size`

Returns a new Map also containing the new key, value pair. If an equivalent key already exists in this Map, it will be replaced.

set(key: K, value: V): Map<K, V>

`Map#set`

Returns a new Map which excludes this `key`

.

delete(key: K): Map<K, V>

`Map#delete`

`remove()`

Note: `delete`

cannot be safely used in IE8, but is provided to mirror the ES6 collection API.

Returns a new Map containing no keys or values.

clear(): Map<K, V>

`Map#clear`

Returns a new Map having updated the value at this `key`

with the return value of calling `updater`

with the existing value, or `notSetValue`

if the key was not set. If called with only a single argument, `updater`

is called with the Map itself.

update(updater: (value: Map<K, V>) => Map<K, V>): Map<K, V> update(key: K, updater: (value: V) => V): Map<K, V> update(key: K, notSetValue: V, updater: (value: V) => V): Map<K, V>

`Map#update`

Equivalent to: `map.set(key, updater(map.get(key, notSetValue)))`

.

Returns a new Map resulting from merging the provided Iterables (or JS objects) into this Map. In other words, this takes each entry of each iterable and sets it on this Map.

merge(...iterables: Iterable<K, V>[]): Map<K, V> merge(...iterables: {[key: string]: V}[]): Map<string, V>

`Map#merge`

If any of the values provided to `merge`

are not Iterable (would return false for `Immutable.Iterable.isIterable`

) then they are deeply converted via `Immutable.fromJS`

before being merged. However, if the value is an Iterable but includes non-iterable JS objects or arrays, those nested values will be preserved.

var x = Immutable.Map({a: 10, b: 20, c: 30}); var y = Immutable.Map({b: 40, a: 50, d: 60}); x.merge(y) // { a: 50, b: 40, c: 30, d: 60 } y.merge(x) // { b: 20, a: 10, d: 60, c: 30 }

Like `merge()`

, `mergeWith()`

returns a new Map resulting from merging the provided Iterables (or JS objects) into this Map, but uses the `merger`

function for dealing with conflicts.

mergeWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: Iterable<K, V>[]): Map<K, V> mergeWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: {[key: string]: V}[]): Map<string, V>

`Map#mergeWith`

var x = Immutable.Map({a: 10, b: 20, c: 30}); var y = Immutable.Map({b: 40, a: 50, d: 60}); x.mergeWith((prev, next) => prev / next, y) // { a: 0.2, b: 0.5, c: 30, d: 60 } y.mergeWith((prev, next) => prev / next, x) // { b: 2, a: 5, d: 60, c: 30 }

Like `merge()`

, but when two Iterables conflict, it merges them as well, recursing deeply through the nested data.

mergeDeep(...iterables: Iterable<K, V>[]): Map<K, V> mergeDeep(...iterables: {[key: string]: V}[]): Map<string, V>

`Map#mergeDeep`

var x = Immutable.fromJS({a: { x: 10, y: 10 }, b: { x: 20, y: 50 } }); var y = Immutable.fromJS({a: { x: 2 }, b: { y: 5 }, c: { z: 3 } }); x.mergeDeep(y) // {a: { x: 2, y: 10 }, b: { x: 20, y: 5 }, c: { z: 3 } }

Like `mergeDeep()`

, but when two non-Iterables conflict, it uses the `merger`

function to determine the resulting value.

mergeDeepWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepWith(merger: (previous?: V, next?: V, key?: K) => V,...iterables: {[key: string]: V}[]): Map<string, V>

`Map#mergeDeepWith`

var x = Immutable.fromJS({a: { x: 10, y: 10 }, b: { x: 20, y: 50 } }); var y = Immutable.fromJS({a: { x: 2 }, b: { y: 5 }, c: { z: 3 } }); x.mergeDeepWith((prev, next) => prev / next, y) // {a: { x: 5, y: 10 }, b: { x: 20, y: 10 }, c: { z: 3 } }

Returns a new Map having set `value`

at this `keyPath`

. If any keys in `keyPath`

do not exist, a new immutable Map will be created at that key.

setIn(keyPath: Array<any>, value: any): Map<K, V> setIn(KeyPath: Iterable<any, any>, value: any): Map<K, V>

`Map#setIn`

Returns a new Map having removed the value at this `keyPath`

. If any keys in `keyPath`

do not exist, no change will occur.

deleteIn(keyPath: Array<any>): Map<K, V> deleteIn(keyPath: Iterable<any, any>): Map<K, V>

`Map#deleteIn`

`removeIn()`

Returns a new Map having applied the `updater`

to the entry found at the keyPath.

updateIn(keyPath: Array<any>, updater: (value: any) => any): Map<K, V> updateIn(keyPath: Array<any>,notSetValue: any,updater: (value: any) => any): Map<K, V> updateIn(keyPath: Iterable<any, any>, updater: (value: any) => any): Map<K, V> updateIn(keyPath: Iterable<any, any>,notSetValue: any,updater: (value: any) => any): Map<K, V>

`Map#updateIn`

If any keys in `keyPath`

do not exist, new Immutable `Map`

s will be created at those keys. If the `keyPath`

does not already contain a value, the `updater`

function will be called with `notSetValue`

, if provided, otherwise `undefined`

.

var data = Immutable.fromJS({ a: { b: { c: 10 } } }); data = data.updateIn(['a', 'b', 'c'], val => val * 2); // { a: { b: { c: 20 } } }

If the `updater`

function returns the same value it was called with, then no change will occur. This is still true if `notSetValue`

is provided.

var data1 = Immutable.fromJS({ a: { b: { c: 10 } } }); data2 = data1.updateIn(['x', 'y', 'z'], 100, val => val); assert(data2 === data1);

A combination of `updateIn`

and `merge`

, returning a new Map, but performing the merge at a point arrived at by following the keyPath. In other words, these two lines are equivalent:

mergeIn(keyPath: Iterable<any, any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeIn(keyPath: Array<any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeIn(keyPath: Array<any>, ...iterables: {[key: string]: V}[]): Map<string, V>

`Map#mergeIn`

x.updateIn(['a', 'b', 'c'], abc => abc.merge(y)); x.mergeIn(['a', 'b', 'c'], y);

A combination of `updateIn`

and `mergeDeep`

, returning a new Map, but performing the deep merge at a point arrived at by following the keyPath. In other words, these two lines are equivalent:

mergeDeepIn(keyPath: Iterable<any, any>,...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepIn(keyPath: Array<any>, ...iterables: Iterable<K, V>[]): Map<K, V> mergeDeepIn(keyPath: Array<any>,...iterables: {[key: string]: V}[]): Map<string, V>

`Map#mergeDeepIn`

x.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)); x.mergeDeepIn(['a', 'b', 'c'], y);

Every time you call one of the above functions, a new immutable Map is created. If a pure function calls a number of these to produce a final return value, then a penalty on performance and memory has been paid by creating all of the intermediate immutable Maps.

withMutations(mutator: (mutable: Map<K, V>) => any): Map<K, V>

`Map#withMutations`

If you need to apply a series of mutations to produce a new immutable Map, `withMutations()`

creates a temporary mutable copy of the Map which can apply mutations in a highly performant manner. In fact, this is exactly how complex mutations like `merge`

are done.

As an example, this results in the creation of 2, not 4, new Maps:

var map1 = Immutable.Map(); var map2 = map1.withMutations(map => { map.set('a', 1).set('b', 2).set('c', 3); }); assert(map1.size === 0); assert(map2.size === 3);

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `set`

and `merge`

may be used mutatively.

Another way to avoid creation of intermediate Immutable maps is to create a mutable copy of this collection. Mutable copies *always* return `this`

, and thus shouldn't be used for equality. Your function should never return a mutable copy of a collection, only use it internally to create a new collection. If possible, use `withMutations`

as it provides an easier to use API.

asMutable(): Map<K, V>

`Map#asMutable`

Note: if the collection is already mutable, `asMutable`

returns itself.

`withMutations`

! Only `set`

and `merge`

may be used mutatively.

The yin to `asMutable`

's yang. Because it applies to mutable collections, this operation is *mutable* and returns itself. Once performed, the mutable copy has become immutable and can be safely returned from a function.

asImmutable(): Map<K, V>

`Map#asImmutable`

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Collection.Keyed#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

var indexedSeq = Immutable.Seq.of('A', 'B', 'C'); indexedSeq.filter(v => v === 'B').toString() // Seq [ 'B' ] var keyedSeq = indexedSeq.toKeyedSeq(); keyedSeq.filter(v => v === 'B').toString() // Seq { 1: 'B' }

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

Note: This is equivalent to `Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

The `hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

var a = List.of(1, 2, 3); var b = List.of(1, 2, 3); assert(a !== b); // different instances var set = Set.of(a); assert(set.has(b) === true);

If two values have the same `hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

get(key: K, notSetValue?: V): V

`Iterable#get`

Note: it is possible a key may be associated with an `undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

getIn(searchKeyPath: Array<any>, notSetValue?: any): any getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any

`Iterable#getIn`

True if the result of following a path of keys or indices through nested Iterables results in a set value.

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

Note: This is equivalent to `Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

Note: This is equivalent to `OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

Note: this will return an ES6 iterator which does not support Immutable JS sequence algorithms. Use `entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns true.

filter(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

Returns a new Iterable of the same type with only the entries for which the `predicate`

function returns false.

filterNot(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

Returns a new Iterable of the same type which includes the same entries, stably sorted by using a `comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

When sorting collections which have no defined order, their ordered equivalents will be returned. e.g. `map.sort()`

returns OrderedMap.

Like `sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<K, V>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Seq.Keyed<G, Iterable<K, V>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

Unlike `Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

If begin is negative, it is offset from the end of the Iterable. e.g. `slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

If end is negative, it is offset from the end of the Iterable. e.g. `slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns false.

skipWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

Returns a new Iterable of the same type which includes entries starting from when `predicate`

first returns true.

skipUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns true.

takeWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

Returns a new Iterable of the same type which includes entries from this Iterable as long as the `predicate`

returns false.

takeUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

Will deeply flatten the Iterable by default, returning an Iterable of the same type, but a `depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

Reduces the Iterable to a value by calling the `reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

Joins values together as a string, inserting a separator between each. The default separator is `","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

For some lazy `Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): number

`Iterable#count`

Regardless of if this Iterable can describe its size lazily (some Seqs cannot), this method will always return the correct size. E.g. it evaluates a lazy `Seq`

if necessary.

If `predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

The `comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

When two values are considered equivalent, the first encountered will be returned. Otherwise, `min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

Like `min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

mapKeys<M>(mapper: (key?: K, value?: V, iter?: Iterable.Keyed<K, V>) => M,context?: any): Iterable.Keyed<M, V>

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a `mapper`

function.

mapEntries<KM, VM>(mapper: (entry?: Array<any>,index?: number,iter?: Iterable.Keyed<K, V>) => Array<any>,context?: any): Iterable.Keyed<KM, VM>

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

A Collection of unique values with `O(log32 N)`

adds and has.

class Set<T> extends Collection.Set<T>

When iterating a Set, the entries will be (value, value) pairs. Iteration order of a Set is undefined, however is stable. Multiple iterations of the same Set will iterate in the same order.

Set values, like Map keys, may be of any type. Equality is determined using `Immutable.is`

, enabling Sets to uniquely include other Immutable collections, custom value types, and NaN.

Create a new immutable Set containing the values of the provided iterable-like.

Set<T>(): Set<T> Set<T>(iter: Iterable.Set<T>): Set<T> Set<T>(iter: Iterable.Indexed<T>): Set<T> Set<K, V>(iter: Iterable.Keyed<K, V>): Set<any> Set<T>(array: Array<T>): Set<T> Set<T>(iterator: Iterator<T>): Set<T> Set<T>(iterable: Object): Set<T>

True if the provided value is a Set

Set.isSet(maybeSet: any): boolean

Creates a new Set containing `values`

.

Set.of<T>(...values: T[]): Set<T>

`Set.fromKeys()`

creates a new immutable Set containing the keys from this Iterable or JavaScript Object.

Set.fromKeys<T>(iter: Iterable<T, any>): Set<T> Set.fromKeys(obj: {[key: string]: any}): Set<string>

size: number

`Collection#size`

Returns a new Set which also includes this value.

add(value: T): Set<T>

Returns a new Set which excludes this value.

delete(value: T): Set<T>

`remove()`

Note: `delete`

cannot be safely used in IE8

Returns a new Set containing no values.

clear(): Set<T>

Returns a Set including any value from `iterables`

that does not already exist in this Set.

union(...iterables: Iterable<any, T>[]): Set<T> union(...iterables: Array<T>[]): Set<T>

`merge()`

Returns a Set which has removed any values not also contained within `iterables`

.

intersect(...iterables: Iterable<any, T>[]): Set<T> intersect(...iterables: Array<T>[]): Set<T>

Returns a Set excluding any values contained within `iterables`

.

subtract(...iterables: Iterable<any, T>[]): Set<T> subtract(...iterables: Array<T>[]): Set<T>

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `add`

may be used mutatively.

withMutations(mutator: (mutable: Set<T>) => any): Set<T>

asMutable(): Set<T>

asImmutable(): Set<T>

Returns Seq.Set.

toSeq(): Seq.Set<T>

`Collection.Set#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<T, T>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<T>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<T>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<T, T>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: T, notSetValue?: T): T

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: T): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: T): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): T

`Iterable#first`

The last value in the Iterable.

last(): T

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<T>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<T, T>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<T, T>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<T>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<T>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<T>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<T>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<T>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<T>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<T>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<T>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => M,context?: any): Iterable<T, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

filter(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

filterNot(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<T, T>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: T, valueB: T) => number): Iterable<T, T>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<T, T>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: T, key?: T, iter?: Iterable<T, T>) => G,context?: any): Seq.Keyed<G, Iterable<T, T>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: T, key?: T, iter?: Iterable<T, T>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<T, T>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<T, T>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<T, T>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<T, T>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<T, T>

`Iterable#skipLast`

`predicate`

first returns false.

skipWhile(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

skipUntil(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<T, T>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<T, T>

`Iterable#takeLast`

`predicate`

returns true.

takeWhile(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

takeUntil(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<T, T>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): number

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: T, key?: T, iter?: Iterable<T, T>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: T, key?: T, iter?: Iterable.Keyed<T, T>) => boolean,context?: any): T

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: T, key?: T, iter?: Iterable.Keyed<T, T>) => boolean,context?: any): T

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: T): T

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: T): T

`Iterable#lastKeyOf`

max(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, T>): boolean isSubset(iter: Array<T>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, T>): boolean isSuperset(iter: Array<T>): boolean

`Iterable#isSuperset`

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

ed.

class OrderedSet<T> extends Set<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.

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

OrderedSet<T>(): OrderedSet<T> OrderedSet<T>(iter: Iterable.Set<T>): OrderedSet<T> OrderedSet<T>(iter: Iterable.Indexed<T>): OrderedSet<T> OrderedSet<K, V>(iter: Iterable.Keyed<K, V>): OrderedSet<any> OrderedSet<T>(array: Array<T>): OrderedSet<T> OrderedSet<T>(iterator: Iterator<T>): OrderedSet<T> OrderedSet<T>(iterable: Object): OrderedSet<T>

True if the provided value is an OrderedSet.

OrderedSet.isOrderedSet(maybeOrderedSet: any): boolean

Creates a new OrderedSet containing `values`

.

OrderedSet.of<T>(...values: T[]): OrderedSet<T>

`OrderedSet.fromKeys()`

creates a new immutable OrderedSet containing the keys from this Iterable or JavaScript Object.

OrderedSet.fromKeys<T>(iter: Iterable<T, any>): OrderedSet<T> OrderedSet.fromKeys(obj: {[key: string]: any}): OrderedSet<string>

size: number

`Collection#size`

Returns a new Set which also includes this value.

add(value: T): Set<T>

`Set#add`

Returns a new Set which excludes this value.

delete(value: T): Set<T>

`Set#delete`

`remove()`

Note: `delete`

cannot be safely used in IE8

Returns a new Set containing no values.

clear(): Set<T>

`Set#clear`

Returns a Set including any value from `iterables`

that does not already exist in this Set.

union(...iterables: Iterable<any, T>[]): Set<T> union(...iterables: Array<T>[]): Set<T>

`Set#union`

`merge()`

Returns a Set which has removed any values not also contained within `iterables`

.

intersect(...iterables: Iterable<any, T>[]): Set<T> intersect(...iterables: Array<T>[]): Set<T>

`Set#intersect`

Returns a Set excluding any values contained within `iterables`

.

subtract(...iterables: Iterable<any, T>[]): Set<T> subtract(...iterables: Array<T>[]): Set<T>

`Set#subtract`

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `add`

may be used mutatively.

withMutations(mutator: (mutable: Set<T>) => any): Set<T>

`Set#withMutations`

asMutable(): Set<T>

`Set#asMutable`

asImmutable(): Set<T>

`Set#asImmutable`

Returns Seq.Set.

toSeq(): Seq.Set<T>

`Collection.Set#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<T, T>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<T>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<T>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<T, T>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: T, notSetValue?: T): T

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: T): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: T): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): T

`Iterable#first`

The last value in the Iterable.

last(): T

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<T>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<T, T>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<T, T>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<T>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<T>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<T>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<T>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<T>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<T>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<T>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<T>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => M,context?: any): Iterable<T, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

filter(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

filterNot(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<T, T>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: T, valueB: T) => number): Iterable<T, T>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<T, T>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: T, key?: T, iter?: Iterable<T, T>) => G,context?: any): Seq.Keyed<G, Iterable<T, T>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: T, key?: T, iter?: Iterable<T, T>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<T, T>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<T, T>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<T, T>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<T, T>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<T, T>

`Iterable#skipLast`

`predicate`

first returns false.

skipWhile(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

skipUntil(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<T, T>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<T, T>

`Iterable#takeLast`

`predicate`

returns true.

takeWhile(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

takeUntil(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): Iterable<T, T>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<T, T>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: T, key?: T, iter?: Iterable<T, T>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any): number

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: T, key?: T, iter?: Iterable<T, T>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: T, key?: T, iter?: Iterable<T, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: T, key?: T, iter?: Iterable.Keyed<T, T>) => boolean,context?: any): T

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: T, key?: T, iter?: Iterable.Keyed<T, T>) => boolean,context?: any): T

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: T): T

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: T): T

`Iterable#lastKeyOf`

max(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: Iterable<T, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, T>): boolean isSubset(iter: Array<T>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, T>): boolean isSuperset(iter: Array<T>): boolean

`Iterable#isSuperset`

Stacks are indexed collections which support very efficient O(1) addition and removal from the front using `unshift(v)`

and `shift()`

.

class Stack<T> extends Collection.Indexed<T>

For familiarity, Stack also provides `push(v)`

, `pop()`

, and `peek()`

, but be aware that they also operate on the front of the list, unlike List or a JavaScript Array.

Note: `reverse()`

or any inherent reverse traversal (`reduceRight`

, `lastIndexOf`

, etc.) is not efficient with a Stack.

Stack is implemented with a Single-Linked List.

Create a new immutable Stack containing the values of the provided iterable-like.

Stack<T>(): Stack<T> Stack<T>(iter: Iterable.Indexed<T>): Stack<T> Stack<T>(iter: Iterable.Set<T>): Stack<T> Stack<K, V>(iter: Iterable.Keyed<K, V>): Stack<any> Stack<T>(array: Array<T>): Stack<T> Stack<T>(iterator: Iterator<T>): Stack<T> Stack<T>(iterable: Object): Stack<T>

The iteration order of the provided iterable is preserved in the resulting `Stack`

.

True if the provided value is a Stack

Stack.isStack(maybeStack: any): boolean

Creates a new Stack containing `values`

.

Stack.of<T>(...values: T[]): Stack<T>

size: number

`Collection#size`

Alias for `Stack.first()`

.

peek(): T

get(key: number, notSetValue?: T): T

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: number): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: T): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): T

`Iterable#first`

The last value in the Iterable.

last(): T

`Iterable#last`

Returns a new Stack with 0 size and no values.

clear(): Stack<T>

Returns a new Stack with the provided `values`

prepended, shifting other values ahead to higher indices.

unshift(...values: T[]): Stack<T>

This is very efficient for Stack.

Like `Stack#unshift`

, but accepts a iterable rather than varargs.

unshiftAll(iter: Iterable<any, T>): Stack<T> unshiftAll(iter: Array<T>): Stack<T>

Returns a new Stack with a size ones less than this Stack, excluding the first item in this Stack, shifting all other values to a lower index.

shift(): Stack<T>

Note: this differs from `Array#shift`

because it returns a new Stack rather than the removed value. Use `first()`

or `peek()`

to get the first value in this Stack.

Alias for `Stack#unshift`

and is not equivalent to `List#push`

.

push(...values: T[]): Stack<T>

Alias for `Stack#unshiftAll`

.

pushAll(iter: Iterable<any, T>): Stack<T> pushAll(iter: Array<T>): Stack<T>

Alias for `Stack#shift`

and is not equivalent to `List#pop`

.

pop(): Stack<T>

Note: Not all methods can be used on a mutable collection or within `withMutations`

! Only `set`

, `push`

, and `pop`

may be used mutatively.

withMutations(mutator: (mutable: Stack<T>) => any): Stack<T>

asMutable(): Stack<T>

asImmutable(): Stack<T>

Returns Seq.Indexed.

toSeq(): Seq.Indexed<T>

`Collection.Indexed#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<number, T>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<T>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<T>

`Iterable#toSetSeq`

If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

fromEntrySeq(): Seq.Keyed<any, any>

`Iterable.Indexed#fromEntrySeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<number, T>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<T>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<number, T>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<number, T>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<T>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<T>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<T>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<T>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<number>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<T>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<number>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<T>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: T, key?: number, iter?: Iterable<number, T>) => M,context?: any): Iterable<number, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

filter(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

filterNot(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<number, T>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: T, valueB: T) => number): Iterable<number, T>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<number, T>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: T, key?: number, iter?: Iterable<number, T>) => G,context?: any): Seq.Keyed<G, Iterable<number, T>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: T, key?: number, iter?: Iterable<number, T>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<number, T>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<number, T>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<number, T>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<number, T>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<number, T>

`Iterable#skipLast`

`predicate`

first returns false.

skipWhile(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

skipUntil(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<number, T>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<number, T>

`Iterable#takeLast`

`predicate`

returns true.

takeWhile(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

takeUntil(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): Iterable<number, T>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<number, T>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: T,key?: number,iter?: Iterable<number, T>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: T, key?: number, iter?: Iterable<number, T>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

Returns an Iterable of the same type with `separator`

between each item in this Iterable.

interpose(separator: T): Iterable.Indexed<T>

`Iterable.Indexed#interpose`

Returns an Iterable of the same type with the provided `iterables`

interleaved into this iterable.

interleave(...iterables: Array<Iterable<any, T>>): Iterable.Indexed<T>

`Iterable.Indexed#interleave`

The resulting Iterable includes the first item from each, then the second from each, etc.

I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C')) // Seq [ 1, 'A', 2, 'B', 3, 'C' ]

The shortest Iterable stops interleave.

I.Seq.of(1,2,3).interleave( I.Seq.of('A','B'), I.Seq.of('X','Y','Z') ) // Seq [ 1, 'A', 'X', 2, 'B', 'Y' ]

Splice returns a new indexed Iterable by replacing a region of this Iterable with new values. If values are not provided, it only skips the region to be removed.

splice(index: number, removeNum: number, ...values: any[]): Iterable.Indexed<T>

`Iterable.Indexed#splice`

`index`

may be a negative number, which indexes back from the end of the Iterable. `s.splice(-2)`

splices after the second to last item.

Seq(['a','b','c','d']).splice(1, 2, 'q', 'r', 's') // Seq ['a', 'q', 'r', 's', 'd']

Returns an Iterable of the same type "zipped" with the provided iterables.

zip(...iterables: Array<Iterable<any, any>>): Iterable.Indexed<any>

`Iterable.Indexed#zip`

Like `zipWith`

, but using the default `zipper`

: creating an `Array`

.

var a = Seq.of(1, 2, 3); var b = Seq.of(4, 5, 6); var c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

Returns an Iterable of the same type "zipped" with the provided iterables by using a custom `zipper`

function.

zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z,otherIterable: Iterable<any, U>): Iterable.Indexed<Z> zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z,otherIterable: Iterable<any, U>,thirdIterable: Iterable<any, V>): Iterable.Indexed<Z> zipWith<Z>(zipper: (...any: Array<any>) => Z,...iterables: Array<Iterable<any, any>>): Iterable.Indexed<Z>

`Iterable.Indexed#zipWith`

var a = Seq.of(1, 2, 3); var b = Seq.of(4, 5, 6); var c = a.zipWith((a, b) => a + b, b); // Seq [ 5, 7, 9 ]

`reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R,value?: T,key?: number,iter?: Iterable<number, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R,value?: T,key?: number,iter?: Iterable<number, T>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any): number

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: T, key?: number, iter?: Iterable<number, T>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): T

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: T, key?: number, iter?: Iterable<number, T>) => boolean,context?: any,notSetValue?: T): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: T,key?: number,iter?: Iterable.Keyed<number, T>) => boolean,context?: any): number

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: T,key?: number,iter?: Iterable.Keyed<number, T>) => boolean,context?: any): number

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: T): number

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: T): number

`Iterable#lastKeyOf`

max(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: T, valueB: T) => number): T

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: T,key?: number,iter?: Iterable<number, T>) => C,comparator?: (valueA: C, valueB: C) => number): T

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

indexOf(searchValue: T): number

`Iterable.Indexed#indexOf`

Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

lastIndexOf(searchValue: T): number

`Iterable.Indexed#lastIndexOf`

Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

findIndex(predicate: (value?: T, index?: number, iter?: Iterable.Indexed<T>) => boolean,context?: any): number

`Iterable.Indexed#findIndex`

Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

findLastIndex(predicate: (value?: T, index?: number, iter?: Iterable.Indexed<T>) => boolean,context?: any): number

`Iterable.Indexed#findLastIndex`

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, T>): boolean isSubset(iter: Array<T>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, T>): boolean isSuperset(iter: Array<T>): boolean

`Iterable#isSuperset`

Returns a Seq.Indexed 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.

Range(start?: number, end?: number, step?: number): Seq.Indexed<number>

Range() // [0,1,2,3,...] Range(10) // [10,11,12,13,...] Range(10,15) // [10,11,12,13,14] Range(10,30,5) // [10,15,20,25] Range(30,10,5) // [30,25,20,15] Range(30,30,5) // []

Returns a Seq.Indexed of `value`

repeated `times`

times. When `times`

is not defined, returns an infinite `Seq`

of `value`

.

Repeat<T>(value: T, times?: number): Seq.Indexed<T>

Repeat('foo') // ['foo','foo','foo',...] Repeat('bar',4) // ['bar','bar','bar','bar']

Creates a new Class which produces Record instances. A record is similar to a JS object, but enforce a specific set of allowed string keys, and have default values.

var ABRecord = Record({a:1, b:2}) var myRecord = new ABRecord({b:3})

Records always have a value for the keys they define. `remove`

ing a key from a record simply resets it to the default value for that key.

myRecord.size // 2 myRecord.get('a') // 1 myRecord.get('b') // 3 myRecordWithoutB = myRecord.remove('b') myRecordWithoutB.get('b') // 2 myRecordWithoutB.size // 2

Values provided to the constructor not found in the Record type will be ignored. For example, in this case, ABRecord is provided a key "x" even though only "a" and "b" have been defined. The value for "x" will be ignored for this record.

var myRecord = new ABRecord({b:3, x:10}) myRecord.get('x') // undefined

Because Records have a known set of string keys, property get access works as expected, however property sets will throw an Error.

Note: IE8 does not support property access. Only use `get()`

when supporting IE8.

myRecord.b // 3 myRecord.b = 5 // throws Error

Record Classes can be extended as well, allowing for custom methods on your Record. This is not a common pattern in functional environments, but is in many JS programs.

Note: TypeScript does not support this type of subclassing.

class ABRecord extends Record({a:1,b:2}) { getAB() { return this.a + this.b; } } var myRecord = new ABRecord({b: 3}) myRecord.getAB() // 4

Record(defaultValues: {[key: string]: any}, name?: string): Record.Class

class Record.Class

Represents a sequence of values, but may not be backed by a concrete data structure.

class Seq<K, V> extends Iterable<K, V>

**Seq is immutable** — Once a Seq is created, it cannot be changed, appended to, rearranged or otherwise modified. Instead, any mutative method called on a `Seq`

will return a new `Seq`

.

**Seq is lazy** — Seq does as little work as necessary to respond to any method call. Values are often created during iteration, including implicit iteration when reducing or converting to a concrete data structure such as a `List`

or JavaScript `Array`

.

For example, the following performs no work, because the resulting Seq's values are never iterated:

var oddSquares = Immutable.Seq.of(1,2,3,4,5,6,7,8) .filter(x => x % 2).map(x => x * x);

Once the Seq is used, it performs only the work necessary. In this example, no intermediate data structures are ever created, filter is only called three times, and map is only called once:

console.log(oddSquares.get(1)); // 9

Seq allows for the efficient chaining of operations, allowing for the expression of logic that can otherwise be very tedious:

Immutable.Seq({a:1, b:1, c:1}) .flip().map(key => key.toUpperCase()).flip().toObject(); // Map { A: 1, B: 1, C: 1 }

As well as expressing logic that would otherwise be memory or time limited:

Immutable.Range(1, Infinity) .skip(1000) .map(n => -n) .filter(n => n % 2 === 0) .take(2) .reduce((r, n) => r * n, 1); // 1006008

Seq is often used to provide a rich collection API to JavaScript Object.

Immutable.Seq({ x: 0, y: 1, z: 2 }).map(v => v * 2).toObject(); // { x: 0, y: 2, z: 4 }

Creates a Seq.

Seq<K, V>(): Seq<K, V> Seq<K, V>(seq: Seq<K, V>): Seq<K, V> Seq<K, V>(iterable: Iterable<K, V>): Seq<K, V> Seq<T>(array: Array<T>): Seq.Indexed<T> Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V> Seq<T>(iterator: Iterator<T>): Seq.Indexed<T> Seq<T>(iterable: Object): Seq.Indexed<T>

Returns a particular kind of `Seq`

based on the input.

- If a
`Seq`

, that same`Seq`

. - If an
`Iterable`

, a`Seq`

of the same kind (Keyed, Indexed, or Set). - If an Array-like, an
`Seq.Indexed`

. - If an Object with an Iterator, an
`Seq.Indexed`

. - If an Iterator, an
`Seq.Indexed`

. - If an Object, a
`Seq.Keyed`

.

True if `maybeSeq`

is a Seq, it is not backed by a concrete structure such as Map, List, or Set.

Seq.isSeq(maybeSeq: any): boolean

Returns a Seq of the values provided. Alias for `Seq.Indexed.of()`

.

Seq.of<T>(...values: T[]): Seq.Indexed<T>

size: number

Because Sequences are lazy and designed to be chained together, they do not cache their results. For example, this map function is called a total of 6 times, as each `join`

iterates the Seq of three values.

cacheResult(): Seq<K, V>

var squares = Seq.of(1,2,3).map(x => x * x); squares.join() + squares.join();

If you know a `Seq`

will be used multiple times, it may be more efficient to first cache it in memory. Here, the map function is called only 3 times.

var squares = Seq.of(1,2,3).map(x => x * x).cacheResult(); squares.join() + squares.join();

Use this method judiciously, as it must fully evaluate a Seq which can be a burden on memory and possibly performance.

Note: after calling `cacheResult`

, a Seq will always have a `size`

.

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

toSeq(): Seq<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

filter(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

filterNot(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

sortBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): Iterable<K, V>

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

groupBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Seq.Keyed<G, Iterable<K, V>>

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

skipWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

skipUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

takeWhile(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

takeUntil(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): Iterable<K, V>

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => Iterable<MK, MV>,context?: any): Iterable<MK, MV> flatMap<MK, MV>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): Iterable<MK, MV>

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

reduce<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

reduceRight<R>(reducer: (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>) => R,initialReduction?: R,context?: any): R

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

count(): number count(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): number

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

find(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

findLast(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): V

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

findEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

findLastEntry(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any,notSetValue?: V): Array<any>

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

findLastKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

maxBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

minBy<C>(comparatorValueMapper: (value?: V, key?: K, iter?: Iterable<K, V>) => C,comparator?: (valueA: C, valueB: C) => number): V

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

`Seq`

which represents key-value pairs.

class Seq.Keyed<K, V> extends Seq<K, V>, Iterable.Keyed<K, V>

Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

Seq.Keyed<K, V>(): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable<any, any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(array: Array<any>): Seq.Keyed<K, V> Seq.Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V> Seq.Keyed<K, V>(iterator: Iterator<any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(iterable: Object): Seq.Keyed<K, V>

size: number

`Seq#size`

Returns itself

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

Because Sequences are lazy and designed to be chained together, they do not cache their results. For example, this map function is called a total of 6 times, as each `join`

iterates the Seq of three values.

cacheResult(): Seq<K, V>

`Seq#cacheResult`

var squares = Seq.of(1,2,3).map(x => x * x); squares.join() + squares.join();

If you know a `Seq`

will be used multiple times, it may be more efficient to first cache it in memory. Here, the map function is called only 3 times.

var squares = Seq.of(1,2,3).map(x => x * x).cacheResult(); squares.join() + squares.join();

Use this method judiciously, as it must fully evaluate a Seq which can be a burden on memory and possibly performance.

Note: after calling `cacheResult`

, a Seq will always have a `size`

.

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

mapKeys<M>(mapper: (key?: K, value?: V, iter?: Iterable.Keyed<K, V>) => M,context?: any): Iterable.Keyed<M, V>

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a `mapper`

function.

mapEntries<KM, VM>(mapper: (entry?: Array<any>,index?: number,iter?: Iterable.Keyed<K, V>) => Array<any>,context?: any): Iterable.Keyed<KM, VM>

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

`Seq`

which represents key-value pairs.

class Seq.Keyed<K, V> extends Seq<K, V>, Iterable.Keyed<K, V>

Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

Seq.Keyed<K, V>(): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable<any, any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(array: Array<any>): Seq.Keyed<K, V> Seq.Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V> Seq.Keyed<K, V>(iterator: Iterator<any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(iterable: Object): Seq.Keyed<K, V>

size: number

`Seq#size`

Returns itself

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

Because Sequences are lazy and designed to be chained together, they do not cache their results. For example, this map function is called a total of 6 times, as each `join`

iterates the Seq of three values.

cacheResult(): Seq<K, V>

`Seq#cacheResult`

var squares = Seq.of(1,2,3).map(x => x * x); squares.join() + squares.join();

If you know a `Seq`

will be used multiple times, it may be more efficient to first cache it in memory. Here, the map function is called only 3 times.

var squares = Seq.of(1,2,3).map(x => x * x).cacheResult(); squares.join() + squares.join();

Use this method judiciously, as it must fully evaluate a Seq which can be a burden on memory and possibly performance.

Note: after calling `cacheResult`

, a Seq will always have a `size`

.

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

`Seq`

which represents key-value pairs.

class Seq.Keyed<K, V> extends Seq<K, V>, Iterable.Keyed<K, V>

Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

Seq.Keyed<K, V>(): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable.Keyed<K, V>): Seq.Keyed<K, V> Seq.Keyed<K, V>(seq: Iterable<any, any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(array: Array<any>): Seq.Keyed<K, V> Seq.Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V> Seq.Keyed<K, V>(iterator: Iterator<any>): Seq.Keyed<K, V> Seq.Keyed<K, V>(iterable: Object): Seq.Keyed<K, V>

size: number

`Seq#size`

Returns itself

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

`join`

iterates the Seq of three values.

cacheResult(): Seq<K, V>

`Seq#cacheResult`

var squares = Seq.of(1,2,3).map(x => x * x); squares.join() + squares.join();

`Seq`

will be used multiple times, it may be more efficient to first cache it in memory. Here, the map function is called only 3 times.

var squares = Seq.of(1,2,3).map(x => x * x).cacheResult(); squares.join() + squares.join();

Note: after calling `cacheResult`

, a Seq will always have a `size`

.

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

The `Iterable`

is a set of (key, value) entries which can be iterated, and is the base class for all collections in `immutable`

, allowing them to make use of all the Iterable methods (such as `map`

and `filter`

).

class Iterable<K, V>

Note: An iterable is always iterated in the same order, however that order may not always be well defined, as is the case for the `Map`

and `Set`

.

Creates an Iterable.

Iterable<K, V>(iterable: Iterable<K, V>): Iterable<K, V> Iterable<T>(array: Array<T>): Iterable.Indexed<T> Iterable<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V> Iterable<T>(iterator: Iterator<T>): Iterable.Indexed<T> Iterable<T>(iterable: Object): Iterable.Indexed<T> Iterable<V>(value: V): Iterable.Indexed<V>

The type of Iterable created is based on the input.

- If an
`Iterable`

, that same`Iterable`

. - If an Array-like, an
`Iterable.Indexed`

. - If an Object with an Iterator, an
`Iterable.Indexed`

. - If an Iterator, an
`Iterable.Indexed`

. - If an Object, an
`Iterable.Keyed`

.

This methods forces the conversion of Objects and Strings to Iterables. If you want to ensure that a Iterable of one item is returned, use `Seq.of`

.

True if `maybeIterable`

is an Iterable, or any of its subclasses.

Iterable.isIterable(maybeIterable: any): boolean

True if `maybeKeyed`

is an Iterable.Keyed, or any of its subclasses.

Iterable.isKeyed(maybeKeyed: any): boolean

True if `maybeIndexed`

is a Iterable.Indexed, or any of its subclasses.

Iterable.isIndexed(maybeIndexed: any): boolean

True if `maybeAssociative`

is either a keyed or indexed Iterable.

Iterable.isAssociative(maybeAssociative: any): boolean

True if `maybeOrdered`

is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

Iterable.isOrdered(maybeOrdered: any): boolean

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`contains()`

The first value in the Iterable.

first(): V

The last value in the Iterable.

last(): V

Returns the value found by following a path of keys or indices through nested Iterables.

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

Deeply converts this Iterable to equivalent JS.

toJS(): any

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

toSeq(): Seq<K, V>

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`predicate`

first returns false.

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`predicate`

returns true.

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`","`

.

join(separator?: string): string

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

Returns the last value for which the `predicate`

returns true.

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

Returns the last [key, value] entry for which the `predicate`

returns true.

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

Returns the last key for which the `predicate`

returns true.

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

max(comparator?: (valueA: V, valueB: V) => number): V

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

Keyed Iterables have discrete keys tied to each value.

class Iterable.Keyed<K, V> extends Iterable<K, V>

When iterating `Iterable.Keyed`

, each iteration will yield a `[K, V]`

tuple, in other words, `Iterable#entries`

is the default iterator for Keyed Iterables.

Creates an Iterable.Keyed

Iterable.Keyed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iter: Iterable<any, any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(array: Array<any>): Iterable.Keyed<K, V> Iterable.Keyed<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V> Iterable.Keyed<K, V>(iterator: Iterator<any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iterable: Object): Iterable.Keyed<K, V>

Similar to `Iterable()`

, however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Keyed Iterables have discrete keys tied to each value.

class Iterable.Keyed<K, V> extends Iterable<K, V>

When iterating `Iterable.Keyed`

, each iteration will yield a `[K, V]`

tuple, in other words, `Iterable#entries`

is the default iterator for Keyed Iterables.

Creates an Iterable.Keyed

Iterable.Keyed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iter: Iterable<any, any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(array: Array<any>): Iterable.Keyed<K, V> Iterable.Keyed<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V> Iterable.Keyed<K, V>(iterator: Iterator<any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iterable: Object): Iterable.Keyed<K, V>

Similar to `Iterable()`

, however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Keyed Iterables have discrete keys tied to each value.

class Iterable.Keyed<K, V> extends Iterable<K, V>

When iterating `Iterable.Keyed`

, each iteration will yield a `[K, V]`

tuple, in other words, `Iterable#entries`

is the default iterator for Keyed Iterables.

Creates an Iterable.Keyed

Iterable.Keyed<K, V>(iter: Iterable.Keyed<K, V>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iter: Iterable<any, any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(array: Array<any>): Iterable.Keyed<K, V> Iterable.Keyed<V>(obj: {[key: string]: V}): Iterable.Keyed<string, V> Iterable.Keyed<K, V>(iterator: Iterator<any>): Iterable.Keyed<K, V> Iterable.Keyed<K, V>(iterable: Object): Iterable.Keyed<K, V>

Similar to `Iterable()`

, however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

class Collection<K, V> extends Iterable<K, V>

Implementations should extend one of the subclasses, `Collection.Keyed`

, `Collection.Indexed`

, or `Collection.Set`

.

size: number

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

toSeq(): Seq<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

`Collection`

which represents key-value pairs.

class Collection.Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V>

size: number

`Collection#size`

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

`Collection`

which represents key-value pairs.

class Collection.Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V>

size: number

`Collection#size`

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

`Collection`

which represents key-value pairs.

class Collection.Keyed<K, V> extends Collection<K, V>, Iterable.Keyed<K, V>

size: number

`Collection#size`

Returns Seq.Keyed.

toSeq(): Seq.Keyed<K, V>

`Iterable#toSeq`

Returns a Seq.Keyed from this Iterable where indices are treated as keys.

toKeyedSeq(): Seq.Keyed<K, V>

`Iterable#toKeyedSeq`

This is useful if you want to operate on an Iterable.Indexed and preserve the [index, value] pairs.

The returned Seq will have identical iteration order as this Iterable.

Example:

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

toIndexedSeq(): Seq.Indexed<V>

`Iterable#toIndexedSeq`

Returns a Seq.Set of the values of this Iterable, discarding keys.

toSetSeq(): Seq.Set<V>

`Iterable#toSetSeq`

True if this and the other Iterable have value equality, as defined by `Immutable.is()`

.

equals(other: Iterable<K, V>): boolean

`Iterable#equals`

`Immutable.is(this, other)`

, but provided to allow for chained expressions.

Computes and returns the hashed identity for this Iterable.

hashCode(): number

`Iterable#hashCode`

`hashCode`

of an Iterable is used to determine potential equality, and is used when adding this to a `Set`

or as a key in a `Map`

, enabling lookup via a different instance.

`hashCode`

, they are not guaranteed to be equal. If two values have different `hashCode`

s, they must not be equal.

get(key: K, notSetValue?: V): V

`Iterable#get`

`undefined`

value, so if `notSetValue`

is not provided and this method returns `undefined`

, that does not guarantee the key was not found.

True if a key exists within this `Iterable`

, using `Immutable.is`

to determine equality

has(key: K): boolean

`Iterable#has`

True if a value exists within this `Iterable`

, using `Immutable.is`

to determine equality

includes(value: V): boolean

`Iterable#includes`

`contains()`

The first value in the Iterable.

first(): V

`Iterable#first`

The last value in the Iterable.

last(): V

`Iterable#last`

Returns the value found by following a path of keys or indices through nested Iterables.

`Iterable#getIn`

hasIn(searchKeyPath: Array<any>): boolean hasIn(searchKeyPath: Iterable<any, any>): boolean

`Iterable#hasIn`

Deeply converts this Iterable to equivalent JS.

toJS(): any

`Iterable#toJS`

`toJSON()`

`Iterable.Indexeds`

, and `Iterable.Sets`

become Arrays, while `Iterable.Keyeds`

become Objects.

Shallowly converts this iterable to an Array, discarding keys.

toArray(): Array<V>

`Iterable#toArray`

Shallowly converts this Iterable to an Object.

toObject(): {[key: string]: V}

`Iterable#toObject`

Throws if keys are not strings.

Converts this Iterable to a Map, Throws if keys are not hashable.

toMap(): Map<K, V>

`Iterable#toMap`

`Map(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Map, maintaining the order of iteration.

toOrderedMap(): OrderedMap<K, V>

`Iterable#toOrderedMap`

`OrderedMap(this.toKeyedSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

toSet(): Set<V>

`Iterable#toSet`

Note: This is equivalent to `Set(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Set, maintaining the order of iteration and discarding keys.

toOrderedSet(): OrderedSet<V>

`Iterable#toOrderedSet`

`OrderedSet(this.valueSeq())`

, but provided for convenience and to allow for chained expressions.

Converts this Iterable to a List, discarding keys.

toList(): List<V>

`Iterable#toList`

Note: This is equivalent to `List(this)`

, but provided to allow for chained expressions.

Converts this Iterable to a Stack, discarding keys. Throws if values are not hashable.

toStack(): Stack<V>

`Iterable#toStack`

Note: This is equivalent to `Stack(this)`

, but provided to allow for chained expressions.

An iterator of this `Iterable`

's keys.

keys(): Iterator<K>

`Iterable#keys`

`keySeq`

instead, if this is what you want.

An iterator of this `Iterable`

's values.

values(): Iterator<V>

`Iterable#values`

`valueSeq`

instead, if this is what you want.

An iterator of this `Iterable`

's entries as `[key, value]`

tuples.

entries(): Iterator<Array<any>>

`Iterable#entries`

`entrySeq`

instead, if this is what you want.

Returns a new Seq.Indexed of the keys of this Iterable, discarding values.

keySeq(): Seq.Indexed<K>

`Iterable#keySeq`

Returns an Seq.Indexed of the values of this Iterable, discarding keys.

valueSeq(): Seq.Indexed<V>

`Iterable#valueSeq`

Returns a new Seq.Indexed of [key, value] tuples.

entrySeq(): Seq.Indexed<Array<any>>

`Iterable#entrySeq`

Returns a new Iterable of the same type with values passed through a `mapper`

function.

map<M>(mapper: (value?: V, key?: K, iter?: Iterable<K, V>) => M,context?: any): Iterable<K, M>

`Iterable#map`

Seq({ a: 1, b: 2 }).map(x => 10 * x) // Seq { a: 10, b: 20 }

`predicate`

function returns true.

`Iterable#filter`

Seq({a:1,b:2,c:3,d:4}).filter(x => x % 2 === 0) // Seq { b: 2, d: 4 }

`predicate`

function returns false.

`Iterable#filterNot`

Seq({a:1,b:2,c:3,d:4}).filterNot(x => x % 2 === 0) // Seq { a: 1, c: 3 }

Returns a new Iterable of the same type in reverse order.

reverse(): Iterable<K, V>

`Iterable#reverse`

`comparator`

.

sort(comparator?: (valueA: V, valueB: V) => number): Iterable<K, V>

`Iterable#sort`

If a `comparator`

is not provided, a default comparator uses `<`

and `>`

.

`comparator(valueA, valueB)`

:

- Returns
`0`

if the elements should not be swapped. - Returns
`-1`

(or any negative number) if`valueA`

comes before`valueB`

- Returns
`1`

(or any positive number) if`valueA`

comes after`valueB`

- Is pure, i.e. it must always return the same value for the same pair of values.

`map.sort()`

returns OrderedMap.

`sort`

, but also accepts a `comparatorValueMapper`

which allows for sorting by more sophisticated means:

`Iterable#sortBy`

hitters.sortBy(hitter => hitter.avgHits);

Returns a `Iterable.Keyed`

of `Iterable.Keyeds`

, grouped by the return value of the `grouper`

function.

`Iterable#groupBy`

Note: This is always an eager operation.

The `sideEffect`

is executed for every entry in the Iterable.

forEach(sideEffect: (value?: V, key?: K, iter?: Iterable<K, V>) => any,context?: any): number

`Iterable#forEach`

`Array#forEach`

, if any call of `sideEffect`

returns `false`

, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).

slice(begin?: number, end?: number): Iterable<K, V>

`Iterable#slice`

`slice(-2)`

returns a Iterable of the last two entries. If it is not provided the new Iterable will begin at the beginning of this Iterable.

`slice(0, -1)`

returns an Iterable of everything but the last entry. If it is not provided, the new Iterable will continue through the end of this Iterable.

If the requested slice is equivalent to the current Iterable, then it will return itself.

Returns a new Iterable of the same type containing all entries except the first.

rest(): Iterable<K, V>

`Iterable#rest`

Returns a new Iterable of the same type containing all entries except the last.

butLast(): Iterable<K, V>

`Iterable#butLast`

Returns a new Iterable of the same type which excludes the first `amount`

entries from this Iterable.

skip(amount: number): Iterable<K, V>

`Iterable#skip`

Returns a new Iterable of the same type which excludes the last `amount`

entries from this Iterable.

skipLast(amount: number): Iterable<K, V>

`Iterable#skipLast`

`predicate`

first returns false.

`Iterable#skipWhile`

Seq.of('dog','frog','cat','hat','god') .skipWhile(x => x.match(/g/)) // Seq [ 'cat', 'hat', 'god' ]

`predicate`

first returns true.

`Iterable#skipUntil`

Seq.of('dog','frog','cat','hat','god') .skipUntil(x => x.match(/hat/)) // Seq [ 'hat', 'god' ]

Returns a new Iterable of the same type which includes the first `amount`

entries from this Iterable.

take(amount: number): Iterable<K, V>

`Iterable#take`

Returns a new Iterable of the same type which includes the last `amount`

entries from this Iterable.

takeLast(amount: number): Iterable<K, V>

`Iterable#takeLast`

`predicate`

returns true.

`Iterable#takeWhile`

Seq.of('dog','frog','cat','hat','god') .takeWhile(x => x.match(/o/)) // Seq [ 'dog', 'frog' ]

`predicate`

returns false.

`Iterable#takeUntil`

Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/)) // ['dog', 'frog']

concat(...valuesOrIterables: any[]): Iterable<K, V>

`Iterable#concat`

For Seqs, all entries will be present in the resulting iterable, even if they have the same key.

Flattens nested Iterables.

flatten(depth?: number): Iterable<any, any> flatten(shallow?: boolean): Iterable<any, any>

`Iterable#flatten`

`depth`

can be provided in the form of a number or boolean (where true means to shallowly flatten one level). A depth of 0 (or shallow: false) will deeply flatten.

Flattens only others Iterable, not Arrays or Objects.

Note: `flatten(true)`

operates on Iterable

Flat-maps the Iterable, returning an Iterable of the same type.

`Iterable#flatMap`

Similar to `iter.map(...).flatten(true)`

.

`reducer`

for every entry in the Iterable and passing along the reduced value.

`Iterable#reduce`

If `initialReduction`

is not provided, or is null, the first item in the Iterable will be used.

Reduces the Iterable in reverse (from the right side).

`Iterable#reduceRight`

Note: Similar to this.reverse().reduce(), and provided for parity with `Array#reduceRight`

.

True if `predicate`

returns true for all entries in the Iterable.

every(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#every`

True if `predicate`

returns true for any entry in the Iterable.

some(predicate: (value?: V, key?: K, iter?: Iterable<K, V>) => boolean,context?: any): boolean

`Iterable#some`

`","`

.

join(separator?: string): string

`Iterable#join`

Returns true if this Iterable includes no values.

isEmpty(): boolean

`Iterable#isEmpty`

`Seq`

, `isEmpty`

might need to iterate to determine emptiness. At most one iteration will occur.

Returns the size of this Iterable.

`Iterable#count`

`Seq`

if necessary.

`predicate`

is provided, then this returns the count of entries in the Iterable for which the `predicate`

returns true.

Returns a `Seq.Keyed`

of counts, grouped by the return value of the `grouper`

function.

countBy<G>(grouper: (value?: V, key?: K, iter?: Iterable<K, V>) => G,context?: any): Map<G, number>

`Iterable#countBy`

Note: This is not a lazy operation.

Returns the first value for which the `predicate`

returns true.

`Iterable#find`

Returns the last value for which the `predicate`

returns true.

`Iterable#findLast`

Note: `predicate`

will be called for each entry in reverse.

Returns the first [key, value] entry for which the `predicate`

returns true.

`Iterable#findEntry`

Returns the last [key, value] entry for which the `predicate`

returns true.

`Iterable#findLastEntry`

Note: `predicate`

will be called for each entry in reverse.

Returns the key for which the `predicate`

returns true.

findKey(predicate: (value?: V, key?: K, iter?: Iterable.Keyed<K, V>) => boolean,context?: any): K

`Iterable#findKey`

Returns the last key for which the `predicate`

returns true.

`Iterable#findLastKey`

Note: `predicate`

will be called for each entry in reverse.

Returns the key associated with the search value, or undefined.

keyOf(searchValue: V): K

`Iterable#keyOf`

Returns the last key associated with the search value, or undefined.

lastKeyOf(searchValue: V): K

`Iterable#lastKeyOf`

max(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#max`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `>`

.

`max`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `>`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`max`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#maxBy`

hitters.maxBy(hitter => hitter.avgHits);

min(comparator?: (valueA: V, valueB: V) => number): V

`Iterable#min`

`comparator`

is used in the same way as `Iterable#sort`

. If it is not provided, the default comparator is `<`

.

`min`

will operate independent of the order of input as long as the comparator is commutative. The default comparator `<`

is commutative *only* when types do not differ.

If `comparator`

returns 0 and either value is NaN, undefined, or null, that value will be returned.

`min`

, but also accepts a `comparatorValueMapper`

which allows for comparing by more sophisticated means:

`Iterable#minBy`

hitters.minBy(hitter => hitter.avgHits);

True if `iter`

includes every value in this Iterable.

isSubset(iter: Iterable<any, V>): boolean isSubset(iter: Array<V>): boolean

`Iterable#isSubset`

True if this Iterable includes every value in `iter`

.

isSuperset(iter: Iterable<any, V>): boolean isSuperset(iter: Array<V>): boolean

`Iterable#isSuperset`

Returns a new Iterable.Keyed of the same type where the keys and values have been flipped.

flip(): Iterable.Keyed<V, K>

`Iterable.Keyed#flip`

Seq({ a: 'z', b: 'y' }).flip() // { z: 'a', y: 'b' }

Returns a new Iterable.Keyed of the same type with keys passed through a `mapper`

function.

`Iterable.Keyed#mapKeys`

Seq({ a: 1, b: 2 }) .mapKeys(x => x.toUpperCase()) // Seq { A: 1, B: 2 }

`mapper`

function.

`Iterable.Keyed#mapEntries`

Seq({ a: 1, b: 2 }) .mapEntries(([k, v]) => [k.toUpperCase(), v * 2]) // Seq { A: 2, B: 4 }

© 2014–2015 Facebook, Inc.

Licensed under the 3-clause BSD License.

https://facebook.github.io/immutable-js/docs/