Options
All
  • Public
  • Public/Protected
  • All
Menu

Immutable.js Docset

Docset for Dash.

Generating the documentation

$ bundle install
$ make

Or to rebuild it from scratch

$ make rebuild

Generating the archive

$ make dist

Index

Modules

"immutable"

"immutable":

Immutable

Immutable:

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; });

Collection

Collection:

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

Implementations should extend one of the subclasses, Collection.Keyed, Collection.Indexed, or Collection.Set.

Indexed

Indexed:

Collection which represents ordered indexed values.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

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

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

size

size: number

All collections maintain their current size as an integer.

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Keyed

Keyed:

Collection which represents key-value pairs.

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

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

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

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

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

size

size: number

All collections maintain their current size as an integer.

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

Set:

Collection which represents values, unassociated with keys or indices.

Collection.Set implementations should guarantee value uniqueness.

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

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

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

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

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

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

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Set

  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

size

size: number

All collections maintain their current size as an integer.

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

size

size: number

All collections maintain their current size as an integer.

butLast

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

    Returns Iterable<K, V>

concat

  • concat(...valuesOrIterables: any[]): Iterable<K, V>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<K, V>

contains

  • contains(value: V): boolean
  • Parameters

    • value: V

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<K, V>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

find

  • find(predicate: function, context?: any, notSetValue?: V): V
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

findLast

  • findLast(predicate: function, context?: any, notSetValue?: V): V
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

first

  • first(): V
  • The first value in the Iterable.

    Returns V

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns number

get

  • get(key: K, notSetValue?: V): V
  • Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

    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.

    Parameters

    • key: K
    • Optional notSetValue: V

    Returns V

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<K, V>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<K, V>>

has

  • has(key: K): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: K

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: V): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: V

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, V>): boolean
  • isSubset(iter: Array<V>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, V>): boolean
  • isSuperset(iter: Array<V>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keySeq

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

    Returns Indexed<K>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<K>

last

  • last(): V
  • The last value in the Iterable.

    Returns V

map

  • map<M>(mapper: function, context?: any): Iterable<K, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): M
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns M

    • Optional context: any

    Returns Iterable<K, M>

max

  • max(comparator?: function): V
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

min

  • min(comparator?: function): V
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<K, V>

reverse

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

    Returns Iterable<K, V>

skip

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipLast

  • skipLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

slice

  • slice(begin?: number, end?: number): Iterable<K, V>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<K, V>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns Iterable<K, V>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<K, V>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<K, V>

take

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeLast

  • takeLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

toArray

  • toArray(): Array<V>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<V>

toIndexedSeq

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

    Returns Indexed<V>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<K, V>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<K, V>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<V>

toMap

  • toMap(): Map<K, V>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<K, V>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: V

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<K, V>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<V>

toSeq

  • toSeq(): Seq<K, V>
  • Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

    Returns Seq<K, V>

toSet

  • toSet(): Set<V>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<V>

toSetSeq

  • toSetSeq(): Set<V>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<V>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<V>

valueSeq

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

    Returns Indexed<V>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<V>

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

size

size: number

Note: this is here as a convenience to work around an issue with TypeScript https://github.com/Microsoft/TypeScript/issues/285, but Iterable does not define size, instead Seq defines size as nullable number, and Collection defines size as always a number.

ignore

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

butLast

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

    Returns Iterable<number, T>

concat

  • concat(...valuesOrIterables: any[]): Iterable<number, T>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<number, T>

contains

  • contains(value: T): boolean
  • Parameters

    • value: T

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): G
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<number, T>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

find

  • find(predicate: function, context?: any, notSetValue?: T): T
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns T

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: T): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns Array<any>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLast

  • findLast(predicate: function, context?: any, notSetValue?: T): T
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns T

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: T): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns Array<any>

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

first

  • first(): T
  • The first value in the Iterable.

    Returns T

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): any
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): any
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns any

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<number, T>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): G
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<number, T>>

has

  • has(key: number): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: number

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: T): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: T

    Returns boolean

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, T>): boolean
  • isSubset(iter: Array<T>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<T>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, T>): boolean
  • isSuperset(iter: Array<T>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<T>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keySeq

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

    Returns Indexed<number>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<number>

last

  • last(): T
  • The last value in the Iterable.

    Returns T

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

map

  • map<M>(mapper: function, context?: any): Iterable<number, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): M
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns M

    • Optional context: any

    Returns Iterable<number, M>

max

  • max(comparator?: function): T
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): T
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): C
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

min

  • min(comparator?: function): T
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): T
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): C
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: T, key?: number, iter?: Iterable<number, T>): R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: T, key?: number, iter?: Iterable<number, T>): R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<number, T>

reverse

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

    Returns Iterable<number, T>

skip

  • skip(amount: number): Iterable<number, T>
  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<number, T>

skipLast

  • skipLast(amount: number): Iterable<number, T>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<number, T>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

slice

  • slice(begin?: number, end?: number): Iterable<number, T>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<number, T>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<number, T>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns Iterable<number, T>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<number, T>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): C
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<number, T>

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

take

  • take(amount: number): Iterable<number, T>
  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<number, T>

takeLast

  • takeLast(amount: number): Iterable<number, T>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<number, T>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<number, T>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: number, iter?: Iterable<number, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: number
          • Optional iter: Iterable<number, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<number, T>

toArray

  • toArray(): Array<T>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<T>

toIndexedSeq

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

    Returns Indexed<T>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<number, T>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<number, T>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<T>

toMap

  • toMap(): Map<number, T>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<number, T>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: T

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<number, T>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

toSet

  • toSet(): Set<T>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<T>

toSetSeq

  • toSetSeq(): Set<T>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<T>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<T>

valueSeq

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

    Returns Indexed<T>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

size

size: number

Note: this is here as a convenience to work around an issue with TypeScript https://github.com/Microsoft/TypeScript/issues/285, but Iterable does not define size, instead Seq defines size as nullable number, and Collection defines size as always a number.

ignore

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

butLast

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

    Returns Iterable<K, V>

concat

  • concat(...valuesOrIterables: any[]): Iterable<K, V>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<K, V>

contains

  • contains(value: V): boolean
  • Parameters

    • value: V

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<K, V>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

find

  • find(predicate: function, context?: any, notSetValue?: V): V
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLast

  • findLast(predicate: function, context?: any, notSetValue?: V): V
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

first

  • first(): V
  • The first value in the Iterable.

    Returns V

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

flip

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

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

    Returns Keyed<V, K>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns number

get

  • get(key: K, notSetValue?: V): V
  • Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

    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.

    Parameters

    • key: K
    • Optional notSetValue: V

    Returns V

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<K, V>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<K, V>>

has

  • has(key: K): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: K

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: V): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: V

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, V>): boolean
  • isSubset(iter: Array<V>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, V>): boolean
  • isSuperset(iter: Array<V>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

keySeq

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

    Returns Indexed<K>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<K>

last

  • last(): V
  • The last value in the Iterable.

    Returns V

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

map

  • map<M>(mapper: function, context?: any): Iterable<K, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): M
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns M

    • Optional context: any

    Returns Iterable<K, M>

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

max

  • max(comparator?: function): V
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

min

  • min(comparator?: function): V
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<K, V>

reverse

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

    Returns Iterable<K, V>

skip

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipLast

  • skipLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

slice

  • slice(begin?: number, end?: number): Iterable<K, V>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<K, V>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns Iterable<K, V>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<K, V>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<K, V>

take

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeLast

  • takeLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

toArray

  • toArray(): Array<V>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<V>

toIndexedSeq

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

    Returns Indexed<V>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<K, V>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<K, V>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<V>

toMap

  • toMap(): Map<K, V>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<K, V>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: V

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<K, V>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

toSet

  • toSet(): Set<V>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<V>

toSetSeq

  • toSetSeq(): Set<V>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<V>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<V>

valueSeq

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

    Returns Indexed<V>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<V>

Set

  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

size

size: number

Note: this is here as a convenience to work around an issue with TypeScript https://github.com/Microsoft/TypeScript/issues/285, but Iterable does not define size, instead Seq defines size as nullable number, and Collection defines size as always a number.

ignore

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

butLast

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

    Returns Iterable<T, T>

concat

  • concat(...valuesOrIterables: any[]): Iterable<T, T>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<T, T>

contains

  • contains(value: T): boolean
  • Parameters

    • value: T

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): G
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<T, T>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

find

  • find(predicate: function, context?: any, notSetValue?: T): T
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns T

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: T): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns Array<any>

findLast

  • findLast(predicate: function, context?: any, notSetValue?: T): T
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns T

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: T): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: T

    Returns Array<any>

first

  • first(): T
  • The first value in the Iterable.

    Returns T

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): any
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): any
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns any

    • Optional context: any

    Returns number

get

  • get(key: T, notSetValue?: T): T
  • Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

    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.

    Parameters

    • key: T
    • Optional notSetValue: T

    Returns T

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<T, T>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): G
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<T, T>>

has

  • has(key: T): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: T

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: T): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: T

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, T>): boolean
  • isSubset(iter: Array<T>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<T>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, T>): boolean
  • isSuperset(iter: Array<T>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<T>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keySeq

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

    Returns Indexed<T>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<T>

last

  • last(): T
  • The last value in the Iterable.

    Returns T

map

  • map<M>(mapper: function, context?: any): Iterable<T, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): M
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns M

    • Optional context: any

    Returns Iterable<T, M>

max

  • max(comparator?: function): T
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): T
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): C
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

min

  • min(comparator?: function): T
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): T
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): C
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>): R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: T, key?: T, iter?: Iterable<T, T>): R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<T, T>

reverse

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

    Returns Iterable<T, T>

skip

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<T, T>

skipLast

  • skipLast(amount: number): Iterable<T, T>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<T, T>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

slice

  • slice(begin?: number, end?: number): Iterable<T, T>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<T, T>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<T, T>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns Iterable<T, T>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<T, T>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): C
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<T, T>

take

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<T, T>

takeLast

  • takeLast(amount: number): Iterable<T, T>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<T, T>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<T, T>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: T, key?: T, iter?: Iterable<T, T>): boolean
        • Parameters

          • Optional value: T
          • Optional key: T
          • Optional iter: Iterable<T, T>

          Returns boolean

    • Optional context: any

    Returns Iterable<T, T>

toArray

  • toArray(): Array<T>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<T>

toIndexedSeq

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

    Returns Indexed<T>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<T, T>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<T, T>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<T>

toMap

  • toMap(): Map<T, T>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<T, T>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: T

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<T, T>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

toSet

  • toSet(): Set<T>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<T>

toSetSeq

  • toSetSeq(): Set<T>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<T>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<T>

valueSeq

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

    Returns Indexed<T>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<T>

size

size: number

Note: this is here as a convenience to work around an issue with TypeScript https://github.com/Microsoft/TypeScript/issues/285, but Iterable does not define size, instead Seq defines size as nullable number, and Collection defines size as always a number.

ignore

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

butLast

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

    Returns Iterable<K, V>

concat

  • concat(...valuesOrIterables: any[]): Iterable<K, V>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<K, V>

contains

  • contains(value: V): boolean
  • Parameters

    • value: V

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<K, V>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

find

  • find(predicate: function, context?: any, notSetValue?: V): V
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

findLast

  • findLast(predicate: function, context?: any, notSetValue?: V): V
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

first

  • first(): V
  • The first value in the Iterable.

    Returns V

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns number

get

  • get(key: K, notSetValue?: V): V
  • Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

    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.

    Parameters

    • key: K
    • Optional notSetValue: V

    Returns V

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<K, V>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<K, V>>

has

  • has(key: K): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: K

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: V): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: V

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, V>): boolean
  • isSubset(iter: Array<V>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, V>): boolean
  • isSuperset(iter: Array<V>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keySeq

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

    Returns Indexed<K>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<K>

last

  • last(): V
  • The last value in the Iterable.

    Returns V

map

  • map<M>(mapper: function, context?: any): Iterable<K, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): M
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns M

    • Optional context: any

    Returns Iterable<K, M>

max

  • max(comparator?: function): V
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

min

  • min(comparator?: function): V
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<K, V>

reverse

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

    Returns Iterable<K, V>

skip

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipLast

  • skipLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

slice

  • slice(begin?: number, end?: number): Iterable<K, V>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<K, V>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns Iterable<K, V>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<K, V>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<K, V>

take

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeLast

  • takeLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

toArray

  • toArray(): Array<V>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<V>

toIndexedSeq

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

    Returns Indexed<V>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<K, V>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<K, V>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<V>

toMap

  • toMap(): Map<K, V>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<K, V>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: V

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<K, V>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<V>

toSeq

  • toSeq(): Seq<K, V>
  • Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

    Returns Seq<K, V>

toSet

  • toSet(): Set<V>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<V>

toSetSeq

  • toSetSeq(): Set<V>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<V>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<V>

valueSeq

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

    Returns Indexed<V>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<V>

List

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

    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.

    Type parameters

    • T

    Returns List<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns List<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns List<T>

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

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns List<any>

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

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns List<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns List<T>

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

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns List<T>

Collection

Collection:

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

Implementations should extend one of the subclasses, Collection.Keyed, Collection.Indexed, or Collection.Set.

Indexed

Indexed:

Collection which represents ordered indexed values.

Keyed

Keyed:

Collection which represents key-value pairs.

Keyed

Keyed:

Keyed Iterables have discrete keys tied to each value.

When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

Set:

Collection which represents values, unassociated with keys or indices.

Collection.Set implementations should guarantee value uniqueness.

Set

Set:

Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

var seq = Seq.Set.of('A', 'B', 'C');
assert.equal(seq.every((v, k) => v === k), true);

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

Indexed

Indexed:

Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

isList

  • isList(maybeList: any): boolean
  • True if the provided value is a List

    Parameters

    • maybeList: any

    Returns boolean

of

  • of<T>(...values: T[]): List<T>
  • Creates a new List containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns List<T>

asImmutable

  • asImmutable(): List<T>
  • see

    Map#asImmutable

    Returns List<T>

asMutable

  • asMutable(): List<T>
  • see

    Map#asMutable

    Returns List<T>

clear

  • Returns a new List with 0 size and no values.

    Returns List<T>

delete

  • delete(index: number): List<T>
  • 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.

    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

    alias

    remove

    Parameters

    • index: number

    Returns List<T>

deleteIn

  • deleteIn(keyPath: Array<any>): List<T>
  • deleteIn(keyPath: Iterable<any, any>): List<T>
  • Returns a new List having removed the value at this keyPath. If any keys in keyPath do not exist, no change will occur.

    alias

    removeIn

    Parameters

    • keyPath: Array<any>

    Returns List<T>

  • Parameters

    Returns List<T>

insert

  • insert(index: number, value: T): List<T>
  • 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.

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

    Parameters

    • index: number
    • value: T

    Returns List<T>

merge

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

    Map#merge

    Parameters

    Returns List<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns List<T>

mergeDeep

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

    Map#mergeDeep

    Parameters

    Returns List<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns List<T>

mergeDeepIn

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

    Map#mergeDeepIn

    Parameters

    Returns List<T>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Indexed<T>[]

    Returns List<T>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Array<T>[]

    Returns List<T>

mergeDeepWith

  • mergeDeepWith(merger: function, ...iterables: Indexed<T>[]): List<T>
  • mergeDeepWith(merger: function, ...iterables: Array<T>[]): List<T>
  • see

    Map#mergeDeepWith

    Parameters

    • merger: function
        • (previous?: T, next?: T, key?: number): T
        • Parameters

          • Optional previous: T
          • Optional next: T
          • Optional key: number

          Returns T

    • Rest ...iterables: Indexed<T>[]

    Returns List<T>

  • Parameters

    • merger: function
        • (previous?: T, next?: T, key?: number): T
        • Parameters

          • Optional previous: T
          • Optional next: T
          • Optional key: number

          Returns T

    • Rest ...iterables: Array<T>[]

    Returns List<T>

mergeIn

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

    Map#mergeIn

    Parameters

    Returns List<T>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Indexed<T>[]

    Returns List<T>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Array<T>[]

    Returns List<T>

mergeWith

  • mergeWith(merger: function, ...iterables: Indexed<T>[]): List<T>
  • mergeWith(merger: function, ...iterables: Array<T>[]): List<T>
  • see

    Map#mergeWith

    Parameters

    • merger: function
        • (previous?: T, next?: T, key?: number): T
        • Parameters

          • Optional previous: T
          • Optional next: T
          • Optional key: number

          Returns T

    • Rest ...iterables: Indexed<T>[]

    Returns List<T>

  • Parameters

    • merger: function
        • (previous?: T, next?: T, key?: number): T
        • Parameters

          • Optional previous: T
          • Optional next: T
          • Optional key: number

          Returns T

    • Rest ...iterables: Array<T>[]

    Returns List<T>

pop

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

    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 List<T>

push

  • push(...values: T[]): List<T>
  • Returns a new List with the provided values appended, starting at this List's size.

    Parameters

    • Rest ...values: T[]

    Returns List<T>

remove

  • remove(index: number): List<T>
  • Parameters

    • index: number

    Returns List<T>

removeIn

  • removeIn(keyPath: Array<any>): List<T>
  • removeIn(keyPath: Iterable<any, any>): List<T>
  • Parameters

    • keyPath: Array<any>

    Returns List<T>

  • Parameters

    Returns List<T>

set

  • set(index: number, value: T): List<T>
  • Returns a new List which includes value at index. If index already exists in this List, it will be replaced.

    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.

    Parameters

    • index: number
    • value: T

    Returns List<T>

setIn

  • setIn(keyPath: Array<any>, value: any): List<T>
  • setIn(keyPath: Iterable<any, any>, value: any): List<T>
  • 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.

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

    Parameters

    • keyPath: Array<any>
    • value: any

    Returns List<T>

  • Parameters

    • keyPath: Iterable<any, any>
    • value: any

    Returns List<T>

setSize

  • setSize(size: number): 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.

    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.

    Parameters

    • size: number

    Returns List<T>

shift

  • 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.

    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 List<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

unshift

  • unshift(...values: T[]): List<T>
  • Returns a new List with the provided values prepended, shifting other values ahead to higher indices.

    Parameters

    • Rest ...values: T[]

    Returns List<T>

update

  • update(updater: function): List<T>
  • update(index: number, updater: function): List<T>
  • update(index: number, notSetValue: T, updater: function): List<T>
  • 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.

    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.

    see

    Map#update

    Parameters

    • updater: function

    Returns List<T>

  • Parameters

    • index: number
    • updater: function
        • (value: T): T
        • Parameters

          • value: T

          Returns T

    Returns List<T>

  • Parameters

    • index: number
    • notSetValue: T
    • updater: function
        • (value: T): T
        • Parameters

          • value: T

          Returns T

    Returns List<T>

updateIn

  • updateIn(keyPath: Array<any>, updater: function): List<T>
  • updateIn(keyPath: Array<any>, notSetValue: any, updater: function): List<T>
  • updateIn(keyPath: Iterable<any, any>, updater: function): List<T>
  • updateIn(keyPath: Iterable<any, any>, notSetValue: any, updater: function): List<T>
  • see

    Map#updateIn

    Parameters

    • keyPath: Array<any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns List<T>

  • Parameters

    • keyPath: Array<any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns List<T>

  • Parameters

    • keyPath: Iterable<any, any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns List<T>

  • Parameters

    • keyPath: Iterable<any, any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns List<T>

withMutations

  • withMutations(mutator: function): 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.

    see

    Map#withMutations

    Parameters

    • mutator: function
        • (mutable: List<T>): any
        • Parameters

          Returns any

    Returns List<T>

Map

  • Map<K, V>(): Map<K, V>
  • Map<K, V>(iter: 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: object): Map<string, V>
  • Map<K, V>(iterator: Iterator<Array<any>>): Map<K, V>
  • Map<K, V>(iterable: Object): Map<K, V>
  • Creates a new Immutable Map.

    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.

    Type parameters

    • K

    • V

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<Array<any>>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Map<string, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Map<K, V>

Collection

Collection:

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

Implementations should extend one of the subclasses, Collection.Keyed, Collection.Indexed, or Collection.Set.

Indexed

Indexed:

Collection which represents ordered indexed values.

Indexed

Indexed:

Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

Keyed

Keyed:

Collection which represents key-value pairs.

Set

Set:

Collection which represents values, unassociated with keys or indices.

Collection.Set implementations should guarantee value uniqueness.

Set

Set:

Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

var seq = Seq.Set.of('A', 'B', 'C');
assert.equal(seq.every((v, k) => v === k), true);

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

Keyed

Keyed:

Keyed Iterables have discrete keys tied to each value.

When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

isMap

  • isMap(maybeMap: any): boolean
  • True if the provided value is a Map

    Parameters

    • maybeMap: any

    Returns boolean

of

  • of(...keyValues: any[]): Map<any, any>
  • Creates a new Map from alternating keys and values

    Parameters

    • Rest ...keyValues: any[]

    Returns Map<any, any>

asImmutable

  • asImmutable(): Map<K, V>
  • 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.

    Returns Map<K, V>

asMutable

  • asMutable(): Map<K, V>
  • 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.

    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.

    Returns Map<K, V>

clear

  • clear(): Map<K, V>
  • Returns a new Map containing no keys or values.

    Returns Map<K, V>

delete

  • delete(key: K): Map<K, V>
  • Returns a new Map which excludes this key.

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

    alias

    remove

    Parameters

    • key: K

    Returns Map<K, V>

deleteIn

  • deleteIn(keyPath: Array<any>): Map<K, V>
  • deleteIn(keyPath: Iterable<any, 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.

    alias

    removeIn

    Parameters

    • keyPath: Array<any>

    Returns Map<K, V>

  • Parameters

    Returns Map<K, V>

merge

  • merge(...iterables: Iterable<K, V>[]): Map<K, V>
  • merge(...iterables: object[]): Map<string, V>
  • 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.

    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 }
    

    Parameters

    Returns Map<K, V>

  • Parameters

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeep

  • mergeDeep(...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeDeep(...iterables: object[]): Map<string, V>
  • Like merge(), but when two Iterables conflict, it merges them as well, recursing deeply through the nested data.

    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 } }
    

    Parameters

    Returns Map<K, V>

  • Parameters

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeepIn

  • 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: object[]): Map<string, V>
  • 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:

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

    Parameters

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeepWith

  • mergeDeepWith(merger: function, ...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeDeepWith(merger: function, ...iterables: object[]): Map<string, V>
  • Like mergeDeep(), but when two non-Iterables conflict, it uses the merger function to determine the resulting value.

    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 } }
    

    Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeIn

  • 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: object[]): Map<string, V>
  • 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:

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

    Parameters

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeWith

  • mergeWith(merger: function, ...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeWith(merger: function, ...iterables: object[]): Map<string, V>
  • 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.

    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 }
    

    Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

remove

  • remove(key: K): Map<K, V>
  • Parameters

    • key: K

    Returns Map<K, V>

removeIn

  • removeIn(keyPath: Array<any>): Map<K, V>
  • removeIn(keyPath: Iterable<any, any>): Map<K, V>
  • Parameters

    • keyPath: Array<any>

    Returns Map<K, V>

  • Parameters

    Returns Map<K, V>

set

  • set(key: K, value: V): Map<K, V>
  • Returns a new Map also containing the new key, value pair. If an equivalent key already exists in this Map, it will be replaced.

    Parameters

    • key: K
    • value: V

    Returns Map<K, V>

setIn

  • setIn(keyPath: Array<any>, value: any): Map<K, V>
  • setIn(KeyPath: Iterable<any, any>, value: any): Map<K, V>
  • 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.

    Parameters

    • keyPath: Array<any>
    • value: any

    Returns Map<K, V>

  • Parameters

    • KeyPath: Iterable<any, any>
    • value: any

    Returns Map<K, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

update

  • update(updater: function): Map<K, V>
  • update(key: K, updater: function): Map<K, V>
  • update(key: K, notSetValue: V, updater: function): 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.

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

    Parameters

    • updater: function
        • (value: Map<K, V>): Map<K, V>
        • Parameters

          • value: Map<K, V>

          Returns Map<K, V>

    Returns Map<K, V>

  • Parameters

    • key: K
    • updater: function
        • (value: V): V
        • Parameters

          • value: V

          Returns V

    Returns Map<K, V>

  • Parameters

    • key: K
    • notSetValue: V
    • updater: function
        • (value: V): V
        • Parameters

          • value: V

          Returns V

    Returns Map<K, V>

updateIn

  • updateIn(keyPath: Array<any>, updater: function): Map<K, V>
  • updateIn(keyPath: Array<any>, notSetValue: any, updater: function): Map<K, V>
  • updateIn(keyPath: Iterable<any, any>, updater: function): Map<K, V>
  • updateIn(keyPath: Iterable<any, any>, notSetValue: any, updater: function): Map<K, V>
  • Returns a new Map having applied the updater to the entry found at the keyPath.

    If any keys in keyPath do not exist, new Immutable Maps 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);
    

    Parameters

    • keyPath: Array<any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Iterable<any, any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Iterable<any, any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

withMutations

  • withMutations(mutator: function): Map<K, V>
  • 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.

    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.

    Parameters

    • mutator: function
        • (mutable: Map<K, V>): any
        • Parameters

          • mutable: Map<K, V>

          Returns any

    Returns Map<K, V>

OrderedMap

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Returns OrderedMap<K, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Parameters

    Returns OrderedMap<K, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Parameters

    Returns OrderedMap<K, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Parameters

    • array: Array<Array<any>>

    Returns OrderedMap<K, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns OrderedMap<string, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Parameters

    Returns OrderedMap<K, V>

  • Creates a new Immutable OrderedMap.

    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"]]);
    

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns OrderedMap<K, V>

Keyed

Keyed:

Collection which represents key-value pairs.

Map

  • Map<K, V>(): Map<K, V>
  • Map<K, V>(iter: 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: object): Map<string, V>
  • Map<K, V>(iterator: Iterator<Array<any>>): Map<K, V>
  • Map<K, V>(iterable: Object): Map<K, V>
  • Creates a new Immutable Map.

    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.

    Type parameters

    • K

    • V

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<Array<any>>

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Map<string, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Map<K, V>

  • Immutable Map is an unordered Iterable.Keyed of (key, value) pairs with O(log32 N) gets and O(log32 N) persistent sets.

    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.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Map<K, V>

isMap

  • isMap(maybeMap: any): boolean
  • True if the provided value is a Map

    Parameters

    • maybeMap: any

    Returns boolean

of

  • of(...keyValues: any[]): Map<any, any>
  • Creates a new Map from alternating keys and values

    Parameters

    • Rest ...keyValues: any[]

    Returns Map<any, any>

isOrderedMap

  • isOrderedMap(maybeOrderedMap: any): boolean
  • True if the provided value is an OrderedMap.

    Parameters

    • maybeOrderedMap: any

    Returns boolean

asImmutable

  • asImmutable(): Map<K, V>
  • 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.

    Returns Map<K, V>

asMutable

  • asMutable(): Map<K, V>
  • 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.

    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.

    Returns Map<K, V>

clear

  • clear(): Map<K, V>
  • Returns a new Map containing no keys or values.

    Returns Map<K, V>

delete

  • delete(key: K): Map<K, V>
  • Returns a new Map which excludes this key.

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

    alias

    remove

    Parameters

    • key: K

    Returns Map<K, V>

deleteIn

  • deleteIn(keyPath: Array<any>): Map<K, V>
  • deleteIn(keyPath: Iterable<any, 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.

    alias

    removeIn

    Parameters

    • keyPath: Array<any>

    Returns Map<K, V>

  • Parameters

    Returns Map<K, V>

merge

  • merge(...iterables: Iterable<K, V>[]): Map<K, V>
  • merge(...iterables: object[]): Map<string, V>
  • 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.

    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 }
    

    Parameters

    Returns Map<K, V>

  • Parameters

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeep

  • mergeDeep(...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeDeep(...iterables: object[]): Map<string, V>
  • Like merge(), but when two Iterables conflict, it merges them as well, recursing deeply through the nested data.

    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 } }
    

    Parameters

    Returns Map<K, V>

  • Parameters

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeepIn

  • 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: object[]): Map<string, V>
  • 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:

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

    Parameters

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeDeepWith

  • mergeDeepWith(merger: function, ...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeDeepWith(merger: function, ...iterables: object[]): Map<string, V>
  • Like mergeDeep(), but when two non-Iterables conflict, it uses the merger function to determine the resulting value.

    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 } }
    

    Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeIn

  • 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: object[]): Map<string, V>
  • 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:

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

    Parameters

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

mergeWith

  • mergeWith(merger: function, ...iterables: Iterable<K, V>[]): Map<K, V>
  • mergeWith(merger: function, ...iterables: object[]): Map<string, V>
  • 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.

    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 }
    

    Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: Iterable<K, V>[]

    Returns Map<K, V>

  • Parameters

    • merger: function
        • (previous?: V, next?: V, key?: K): V
        • Parameters

          • Optional previous: V
          • Optional next: V
          • Optional key: K

          Returns V

    • Rest ...iterables: object[]
      • [key: string]: V

    Returns Map<string, V>

remove

  • remove(key: K): Map<K, V>
  • Parameters

    • key: K

    Returns Map<K, V>

removeIn

  • removeIn(keyPath: Array<any>): Map<K, V>
  • removeIn(keyPath: Iterable<any, any>): Map<K, V>
  • Parameters

    • keyPath: Array<any>

    Returns Map<K, V>

  • Parameters

    Returns Map<K, V>

set

  • set(key: K, value: V): Map<K, V>
  • Returns a new Map also containing the new key, value pair. If an equivalent key already exists in this Map, it will be replaced.

    Parameters

    • key: K
    • value: V

    Returns Map<K, V>

setIn

  • setIn(keyPath: Array<any>, value: any): Map<K, V>
  • setIn(KeyPath: Iterable<any, any>, value: any): Map<K, V>
  • 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.

    Parameters

    • keyPath: Array<any>
    • value: any

    Returns Map<K, V>

  • Parameters

    • KeyPath: Iterable<any, any>
    • value: any

    Returns Map<K, V>

update

  • update(updater: function): Map<K, V>
  • update(key: K, updater: function): Map<K, V>
  • update(key: K, notSetValue: V, updater: function): 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.

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

    Parameters

    • updater: function
        • (value: Map<K, V>): Map<K, V>
        • Parameters

          • value: Map<K, V>

          Returns Map<K, V>

    Returns Map<K, V>

  • Parameters

    • key: K
    • updater: function
        • (value: V): V
        • Parameters

          • value: V

          Returns V

    Returns Map<K, V>

  • Parameters

    • key: K
    • notSetValue: V
    • updater: function
        • (value: V): V
        • Parameters

          • value: V

          Returns V

    Returns Map<K, V>

updateIn

  • updateIn(keyPath: Array<any>, updater: function): Map<K, V>
  • updateIn(keyPath: Array<any>, notSetValue: any, updater: function): Map<K, V>
  • updateIn(keyPath: Iterable<any, any>, updater: function): Map<K, V>
  • updateIn(keyPath: Iterable<any, any>, notSetValue: any, updater: function): Map<K, V>
  • Returns a new Map having applied the updater to the entry found at the keyPath.

    If any keys in keyPath do not exist, new Immutable Maps 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);
    

    Parameters

    • keyPath: Array<any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Array<any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Iterable<any, any>
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

  • Parameters

    • keyPath: Iterable<any, any>
    • notSetValue: any
    • updater: function
        • (value: any): any
        • Parameters

          • value: any

          Returns any

    Returns Map<K, V>

withMutations

  • withMutations(mutator: function): Map<K, V>
  • 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.

    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.

    Parameters

    • mutator: function
        • (mutable: Map<K, V>): any
        • Parameters

          • mutable: Map<K, V>

          Returns any

    Returns Map<K, V>

OrderedSet

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

    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.

    Type parameters

    • T

    Returns OrderedSet<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

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

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns OrderedSet<any>

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

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns OrderedSet<T>

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

    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.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

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

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns OrderedSet<T>

Set

  • Set<T>(): Set<T>
  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Create a new immutable Set containing the values of the provided iterable-like.

    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.

    Type parameters

    • T

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

fromKeys

  • fromKeys<T>(iter: Iterable<T, any>): Set<T>
  • fromKeys(obj: object): Set<string>
  • Set.fromKeys() creates a new immutable Set containing the keys from this Iterable or JavaScript Object.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Parameters

    • obj: object
      • [key: string]: any

    Returns Set<string>

isSet

  • isSet(maybeSet: any): boolean
  • True if the provided value is a Set

    Parameters

    • maybeSet: any

    Returns boolean

of

  • of<T>(...values: T[]): Set<T>
  • Creates a new Set containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Set<T>

fromKeys

  • OrderedSet.fromKeys() creates a new immutable OrderedSet containing the keys from this Iterable or JavaScript Object.

    Type parameters

    • T

    Parameters

    Returns OrderedSet<T>

  • Parameters

    • obj: object
      • [key: string]: any

    Returns OrderedSet<string>

isOrderedSet

  • isOrderedSet(maybeOrderedSet: any): boolean
  • True if the provided value is an OrderedSet.

    Parameters

    • maybeOrderedSet: any

    Returns boolean

of

  • Creates a new OrderedSet containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns OrderedSet<T>

add

  • add(value: T): Set<T>
  • Returns a new Set which also includes this value.

    Parameters

    • value: T

    Returns Set<T>

asImmutable

  • asImmutable(): Set<T>
  • see

    Map#asImmutable

    Returns Set<T>

asMutable

  • asMutable(): Set<T>
  • see

    Map#asMutable

    Returns Set<T>

clear

  • clear(): Set<T>
  • Returns a new Set containing no values.

    Returns Set<T>

delete

  • delete(value: T): Set<T>
  • Returns a new Set which excludes this value.

    Note: delete cannot be safely used in IE8

    alias

    remove

    Parameters

    • value: T

    Returns Set<T>

intersect

  • intersect(...iterables: Iterable<any, T>[]): Set<T>
  • intersect(...iterables: Array<T>[]): Set<T>
  • Returns a Set which has removed any values not also contained within iterables.

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

merge

  • merge(...iterables: Iterable<any, T>[]): Set<T>
  • merge(...iterables: Array<T>[]): Set<T>
  • Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

remove

  • remove(value: T): Set<T>
  • Parameters

    • value: T

    Returns Set<T>

subtract

  • subtract(...iterables: Iterable<any, T>[]): Set<T>
  • subtract(...iterables: Array<T>[]): Set<T>
  • Returns a Set excluding any values contained within iterables.

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

union

  • union(...iterables: Iterable<any, T>[]): Set<T>
  • union(...iterables: Array<T>[]): Set<T>
  • Returns a Set including any value from iterables that does not already exist in this Set.

    alias

    merge

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

withMutations

  • withMutations(mutator: function): Set<T>
  • Note: Not all methods can be used on a mutable collection or within withMutations! Only add may be used mutatively.

    see

    Map#withMutations

    Parameters

    • mutator: function
        • (mutable: Set<T>): any
        • Parameters

          • mutable: Set<T>

          Returns any

    Returns Set<T>

Record

  • Record(defaultValues: object, name?: string): Class
  • 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. removeing 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
    

    Parameters

    • defaultValues: object
      • [key: string]: any
    • Optional name: string

    Returns Class

Class

  • __call(): Map<string, any>
  • __call(values: object): Map<string, any>
  • __call(values: Iterable<string, any>): Map<string, any>
  • Returns Map<string, any>

  • Parameters

    • values: object
      • [key: string]: any

    Returns Map<string, any>

  • Parameters

    Returns Map<string, any>

constructor

  • Returns Class

  • Parameters

    • values: object
      • [key: string]: any

    Returns Class

  • Parameters

    Returns Class

Seq

  • Creates a Seq.

    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.

    Type parameters

    • K

    • V

    Returns Seq<K, V>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • K

    • V

    Parameters

    • seq: Seq<K, V>

    Returns Seq<K, V>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • K

    • V

    Parameters

    Returns Seq<K, V>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Represents a sequence of values, but may not be backed by a concrete data structure.

    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 }
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

Indexed

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Returns Indexed<T>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Always returns Seq.Indexed, discarding associated keys and supplying incrementing indices.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

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

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

size

size: number

Some Seqs can describe their size lazily. When this is the case, size will be an integer. Otherwise it will be undefined.

For example, Seqs returned from map() or reverse() preserve the size of the original Seq while filter() does not.

Note: Range, Repeat and Seqs made from Arrays and Objects will always have a size.

of

  • of<T>(...values: T[]): Indexed<T>
  • Provides an Seq.Indexed of the values provided.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Indexed<T>

Seq

  • Creates a Seq.

    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.

    Type parameters

    • K

    • V

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    • seq: Seq<K, V>

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    Returns Seq<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

cacheResult

  • cacheResult(): Seq<number, T>
  • 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.

    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.

    Returns Seq<number, T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Iterable

  • Creates an Iterable.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Iterable<K, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates an Iterable.

    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.

    Type parameters

    • V

    Parameters

    • value: V

    Returns Indexed<V>

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Keyed

  • Keyed<K, V>(): Keyed<K, V>
  • Keyed<K, V>(seq: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(seq: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Returns Keyed<K, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Always returns a Seq.Keyed, if input is not keyed, expects an iterable of [K, V] tuples.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

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

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

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

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

size

size: number

Some Seqs can describe their size lazily. When this is the case, size will be an integer. Otherwise it will be undefined.

For example, Seqs returned from map() or reverse() preserve the size of the original Seq while filter() does not.

Note: Range, Repeat and Seqs made from Arrays and Objects will always have a size.

Seq

  • Creates a Seq.

    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.

    Type parameters

    • K

    • V

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    • seq: Seq<K, V>

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    Returns Seq<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

cacheResult

  • cacheResult(): Seq<K, V>
  • 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.

    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.

    Returns Seq<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns itself

    Returns Keyed<K, V>

Set

  • Always returns a Seq.Set, discarding associated indices or keys.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Returns Set<T>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Seq which represents a set of values.

    Because Seq are often lazy, Seq.Set does not provide the same guarantee of value uniqueness as the concrete Set.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

Iterable

Iterable:

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).

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.

Indexed

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

  • Creates a new Iterable.Indexed.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • K

    • V

    Parameters

    Returns Indexed<any>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

    Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

    All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

findIndex

  • findIndex(predicate: function, context?: any): number
  • findIndex(predicate: function, context?: any): number
  • Returns the first index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

findLastIndex

  • findLastIndex(predicate: function, context?: any): number
  • findLastIndex(predicate: function, context?: any): number
  • Returns the last index in the Iterable where a value satisfies the provided predicate function. Otherwise -1 is returned.

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

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

    Parameters

    • predicate: function
        • (value?: T, index?: number, iter?: Indexed<T>): boolean
        • Parameters

          • Optional value: T
          • Optional index: number
          • Optional iter: Indexed<T>

          Returns boolean

    • Optional context: any

    Returns number

fromEntrySeq

  • fromEntrySeq(): Keyed<any, any>
  • fromEntrySeq(): Keyed<any, any>
  • If this is an iterable of [key, value] entry tuples, it will return a Seq.Keyed of those entries.

    Returns Keyed<any, any>

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

    Returns Keyed<any, any>

get

  • get(index: number, notSetValue?: T): T
  • get(index: number, notSetValue?: T): T
  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

  • Returns the value associated with the provided index, or notSetValue if the index is beyond the bounds of the Iterable.

    index may be a negative number, which indexes back from the end of the Iterable. s.get(-1) gets the last item in the Iterable.

    Parameters

    • index: number
    • Optional notSetValue: T

    Returns T

indexOf

  • indexOf(searchValue: T): number
  • indexOf(searchValue: T): number
  • Returns the first index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

interleave

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

  • Returns an Iterable of the same type with the provided iterables interleaved into this iterable.

    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' ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, T>>

    Returns Indexed<T>

interpose

  • interpose(separator: T): Indexed<T>
  • interpose(separator: T): Indexed<T>
  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

  • Returns an Iterable of the same type with separator between each item in this Iterable.

    Parameters

    • separator: T

    Returns Indexed<T>

lastIndexOf

  • lastIndexOf(searchValue: T): number
  • lastIndexOf(searchValue: T): number
  • Returns the last index at which a given value can be found in the Iterable, or -1 if it is not present.

    Parameters

    • searchValue: T

    Returns number

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

    Parameters

    • searchValue: T

    Returns number

splice

  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • splice(index: number, removeNum: number, ...values: any[]): Indexed<T>
  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

  • 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.

    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']
    

    Parameters

    • index: number
    • removeNum: number
    • Rest ...values: any[]

    Returns Indexed<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

zip

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

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

    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 ] ]
    

    Parameters

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<any>

zipWith

  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • zipWith<U, Z>(zipper: function, otherIterable: Iterable<any, U>): Indexed<Z>
  • zipWith<U, V, Z>(zipper: function, otherIterable: Iterable<any, U>, thirdIterable: Iterable<any, V>): Indexed<Z>
  • zipWith<Z>(zipper: function, ...iterables: Array<Iterable<any, any>>): Indexed<Z>
  • Returns an Iterable of the same type "zipped" with the provided iterables by using a custom zipper function.

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

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

    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 ]
    

    Type parameters

    • U

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U): Z
        • Parameters

          • value: T
          • otherValue: U

          Returns Z

    • otherIterable: Iterable<any, U>

    Returns Indexed<Z>

  • Type parameters

    • U

    • V

    • Z

    Parameters

    • zipper: function
        • (value: T, otherValue: U, thirdValue: V): Z
        • Parameters

          • value: T
          • otherValue: U
          • thirdValue: V

          Returns Z

    • otherIterable: Iterable<any, U>
    • thirdIterable: Iterable<any, V>

    Returns Indexed<Z>

  • Type parameters

    • Z

    Parameters

    • zipper: function
        • (...any: Array<any>): Z
        • Parameters

          • Rest ...any: Array<any>

          Returns Z

    • Rest ...iterables: Array<Iterable<any, any>>

    Returns Indexed<Z>

Keyed

  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Keyed<K, V>(iter: Keyed<K, V>): Keyed<K, V>
  • Keyed<K, V>(iter: Iterable<any, any>): Keyed<K, V>
  • Keyed<K, V>(array: Array<any>): Keyed<K, V>
  • Keyed<V>(obj: object): Keyed<string, V>
  • Keyed<K, V>(iterator: Iterator<any>): Keyed<K, V>
  • Keyed<K, V>(iterable: Object): Keyed<K, V>
  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

  • Creates an Iterable.Keyed

    Similar to Iterable(), however it expects iterable-likes of [K, V] tuples if not constructed from a Iterable.Keyed or JS Object.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • array: Array<any>

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    Returns Keyed<K, V>

  • Keyed Iterables have discrete keys tied to each value.

    When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

    Type parameters

    • K

    • V

    Parameters

    • iterable: Object

    Returns Keyed<K, V>

findKey

  • findKey(predicate: function, context?: any): K
  • findKey(predicate: function, context?: any): K
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

findLastKey

  • findLastKey(predicate: function, context?: any): K
  • findLastKey(predicate: function, context?: any): K
  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

  • Returns the last key for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Keyed<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Keyed<K, V>

          Returns boolean

    • Optional context: any

    Returns K

flip

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

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

    Returns Keyed<V, K>

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

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

    Returns Keyed<V, K>

keyOf

  • keyOf(searchValue: V): K
  • keyOf(searchValue: V): K
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

lastKeyOf

  • lastKeyOf(searchValue: V): K
  • lastKeyOf(searchValue: V): K
  • Returns the last key associated with the search value, or undefined.

    Parameters

    • searchValue: V

    Returns K

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

    Parameters

    • searchValue: V

    Returns K

mapEntries

  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • mapEntries<KM, VM>(mapper: function, context?: any): Keyed<KM, VM>
  • Returns a new Iterable.Keyed of the same type with entries ([key, value] tuples) passed through a mapper function.

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

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

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

    Type parameters

    • KM

    • VM

    Parameters

    • mapper: function
        • (entry?: Array<any>, index?: number, iter?: Keyed<K, V>): Array<any>
        • Parameters

          • Optional entry: Array<any>
          • Optional index: number
          • Optional iter: Keyed<K, V>

          Returns Array<any>

    • Optional context: any

    Returns Keyed<KM, VM>

mapKeys

  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • mapKeys<M>(mapper: function, context?: any): Keyed<M, V>
  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

  • 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 }
    

    Type parameters

    • M

    Parameters

    • mapper: function
        • (key?: K, value?: V, iter?: Keyed<K, V>): M
        • Parameters

          • Optional key: K
          • Optional value: V
          • Optional iter: Keyed<K, V>

          Returns M

    • Optional context: any

    Returns Keyed<M, V>

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

isAssociative

  • isAssociative(maybeAssociative: any): boolean
  • isAssociative(maybeAssociative: any): boolean
  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

  • True if maybeAssociative is either a keyed or indexed Iterable.

    Parameters

    • maybeAssociative: any

    Returns boolean

isIndexed

  • isIndexed(maybeIndexed: any): boolean
  • isIndexed(maybeIndexed: any): boolean
  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

  • True if maybeIndexed is a Iterable.Indexed, or any of its subclasses.

    Parameters

    • maybeIndexed: any

    Returns boolean

isIterable

  • isIterable(maybeIterable: any): boolean
  • isIterable(maybeIterable: any): boolean
  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

  • True if maybeIterable is an Iterable, or any of its subclasses.

    Parameters

    • maybeIterable: any

    Returns boolean

isKeyed

  • isKeyed(maybeKeyed: any): boolean
  • isKeyed(maybeKeyed: any): boolean
  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

  • True if maybeKeyed is an Iterable.Keyed, or any of its subclasses.

    Parameters

    • maybeKeyed: any

    Returns boolean

isOrdered

  • isOrdered(maybeOrdered: any): boolean
  • isOrdered(maybeOrdered: any): boolean
  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

  • True if maybeOrdered is an Iterable where iteration order is well defined. True for Iterable.Indexed as well as OrderedMap and OrderedSet.

    Parameters

    • maybeOrdered: any

    Returns boolean

Set

  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Similar to Iterable(), but always returns a Iterable.Set.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

    Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

    var seq = Seq.Set.of('A', 'B', 'C');
    assert.equal(seq.every((v, k) => v === k), true);
    

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

size

size: number

Some Seqs can describe their size lazily. When this is the case, size will be an integer. Otherwise it will be undefined.

For example, Seqs returned from map() or reverse() preserve the size of the original Seq while filter() does not.

Note: Range, Repeat and Seqs made from Arrays and Objects will always have a size.

of

  • of<T>(...values: T[]): Set<T>
  • Returns a Seq.Set of the provided values

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Set<T>

Seq

  • Creates a Seq.

    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.

    Type parameters

    • K

    • V

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    • seq: Seq<K, V>

    Returns Seq<K, V>

  • Type parameters

    • K

    • V

    Parameters

    Returns Seq<K, V>

  • Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Indexed<T>

  • Type parameters

    • V

    Parameters

    • obj: object
      • [key: string]: V

    Returns Keyed<string, V>

  • Type parameters

    • T

    Parameters

    Returns Indexed<T>

  • Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Indexed<T>

cacheResult

  • cacheResult(): Seq<T, T>
  • 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.

    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.

    Returns Seq<T, T>

toSeq

  • toSeq(): Set<T>
  • Returns itself

    Returns Set<T>

size

size: number

Some Seqs can describe their size lazily. When this is the case, size will be an integer. Otherwise it will be undefined.

For example, Seqs returned from map() or reverse() preserve the size of the original Seq while filter() does not.

Note: Range, Repeat and Seqs made from Arrays and Objects will always have a size.

isSeq

  • isSeq(maybeSeq: any): boolean
  • True if maybeSeq is a Seq, it is not backed by a concrete structure such as Map, List, or Set.

    Parameters

    • maybeSeq: any

    Returns boolean

of

  • of<T>(...values: T[]): Indexed<T>
  • Returns a Seq of the values provided. Alias for Seq.Indexed.of().

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Indexed<T>

butLast

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

    Returns Iterable<K, V>

cacheResult

  • cacheResult(): Seq<K, V>
  • 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.

    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.

    Returns Seq<K, V>

concat

  • concat(...valuesOrIterables: any[]): Iterable<K, V>
  • Returns a new Iterable of the same type with other values and iterable-like concatenated to this one.

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

    Parameters

    • Rest ...valuesOrIterables: any[]

    Returns Iterable<K, V>

contains

  • contains(value: V): boolean
  • Parameters

    • value: V

    Returns boolean

count

  • count(): number
  • count(predicate: function, context?: any): number
  • Returns the size of this Iterable.

    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 number

  • Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns number

countBy

  • countBy<G>(grouper: function, context?: any): Map<G, number>
  • Returns a Seq.Keyed of counts, grouped by the return value of the grouper function.

    Note: This is not a lazy operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Map<G, number>

entries

  • An iterator of this Iterable's entries as [key, value] tuples.

    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 Iterator<Array<any>>

entrySeq

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

    Returns Indexed<Array<any>>

equals

  • equals(other: Iterable<K, V>): boolean
  • True if this and the other Iterable have value equality, as defined by Immutable.is().

    Note: This is equivalent to Immutable.is(this, other), but provided to allow for chained expressions.

    Parameters

    Returns boolean

every

  • every(predicate: function, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

filter

  • filter(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

filterNot

  • filterNot(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type with only the entries for which the predicate function returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

find

  • find(predicate: function, context?: any, notSetValue?: V): V
  • Returns the value for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findEntry

  • findEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

findLast

  • findLast(predicate: function, context?: any, notSetValue?: V): V
  • Returns the last value for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns V

findLastEntry

  • findLastEntry(predicate: function, context?: any, notSetValue?: V): Array<any>
  • Returns the last [key, value] entry for which the predicate returns true.

    Note: predicate will be called for each entry in reverse.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any
    • Optional notSetValue: V

    Returns Array<any>

first

  • first(): V
  • The first value in the Iterable.

    Returns V

flatMap

  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • flatMap<MK, MV>(mapper: function, context?: any): Iterable<MK, MV>
  • Flat-maps the Iterable, returning an Iterable of the same type.

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

    Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns Iterable<MK, MV>

    • Optional context: any

    Returns Iterable<MK, MV>

  • Type parameters

    • MK

    • MV

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns Iterable<MK, MV>

flatten

  • flatten(depth?: number): Iterable<any, any>
  • flatten(shallow?: boolean): Iterable<any, any>
  • Flattens nested Iterables.

    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> and returns Iterable

    Parameters

    • Optional depth: number

    Returns Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns Iterable<any, any>

forEach

  • forEach(sideEffect: function, context?: any): number
  • The sideEffect is executed for every entry in the Iterable.

    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).

    Parameters

    • sideEffect: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): any
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns any

    • Optional context: any

    Returns number

get

  • get(key: K, notSetValue?: V): V
  • Returns the value associated with the provided key, or notSetValue if the Iterable does not contain this key.

    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.

    Parameters

    • key: K
    • Optional notSetValue: V

    Returns V

getIn

  • getIn(searchKeyPath: Array<any>, notSetValue?: any): any
  • getIn(searchKeyPath: Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: Array<any>
    • Optional notSetValue: any

    Returns any

  • Parameters

    • searchKeyPath: Iterable<any, any>
    • Optional notSetValue: any

    Returns any

groupBy

  • groupBy<G>(grouper: function, context?: any): Keyed<G, Iterable<K, V>>
  • Returns a Iterable.Keyed of Iterable.Keyeds, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type parameters

    • G

    Parameters

    • grouper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): G
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns G

    • Optional context: any

    Returns Keyed<G, Iterable<K, V>>

has

  • has(key: K): boolean
  • True if a key exists within this Iterable, using Immutable.is to determine equality

    Parameters

    • key: K

    Returns boolean

hasIn

  • hasIn(searchKeyPath: Array<any>): boolean
  • hasIn(searchKeyPath: Iterable<any, any>): boolean
  • True if the result of following a path of keys or indices through nested Iterables results in a set value.

    Parameters

    • searchKeyPath: Array<any>

    Returns boolean

  • Parameters

    Returns boolean

hashCode

  • hashCode(): number
  • Computes and returns the hashed identity for this Iterable.

    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 hashCodes, they must not be equal.

    Returns number

includes

  • includes(value: V): boolean
  • True if a value exists within this Iterable, using Immutable.is to determine equality

    alias

    contains

    Parameters

    • value: V

    Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns true if this Iterable includes no values.

    For some lazy Seq, isEmpty might need to iterate to determine emptiness. At most one iteration will occur.

    Returns boolean

isSubset

  • isSubset(iter: Iterable<any, V>): boolean
  • isSubset(iter: Array<V>): boolean
  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

isSuperset

  • isSuperset(iter: Iterable<any, V>): boolean
  • isSuperset(iter: Array<V>): boolean
  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: Array<V>

    Returns boolean

join

  • join(separator?: string): string
  • Joins values together as a string, inserting a separator between each. The default separator is ",".

    Parameters

    • Optional separator: string

    Returns string

keySeq

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

    Returns Indexed<K>

keys

  • An iterator of this Iterable's 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.

    Returns Iterator<K>

last

  • last(): V
  • The last value in the Iterable.

    Returns V

map

  • map<M>(mapper: function, context?: any): Iterable<K, M>
  • Returns a new Iterable of the same type with values passed through a mapper function.

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

    Type parameters

    • M

    Parameters

    • mapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): M
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns M

    • Optional context: any

    Returns Iterable<K, M>

max

  • max(comparator?: function): V
  • Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

maxBy

  • maxBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

min

  • min(comparator?: function): V
  • Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns V

minBy

  • minBy<C>(comparatorValueMapper: function, comparator?: function): V
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns V

reduce

  • reduce<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable to a value by calling the 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.

    see

    Array#reduce.

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

reduceRight

  • reduceRight<R>(reducer: function, initialReduction?: R, context?: any): R
  • Reduces the Iterable in reverse (from the right side).

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

    Type parameters

    • R

    Parameters

    • reducer: function
        • (reduction?: R, value?: V, key?: K, iter?: Iterable<K, V>): R
        • Parameters

          • Optional reduction: R
          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

rest

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

    Returns Iterable<K, V>

reverse

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

    Returns Iterable<K, V>

skip

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipLast

  • skipLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

skipUntil

  • skipUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

skipWhile

  • skipWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries starting from when predicate first returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

slice

  • slice(begin?: number, end?: number): Iterable<K, V>
  • Returns a new Iterable of the same type representing a portion of this Iterable from start up to but not including end.

    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.

    Parameters

    • Optional begin: number
    • Optional end: number

    Returns Iterable<K, V>

some

  • some(predicate: function, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns boolean

sort

  • sort(comparator?: function): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the same entries, stably sorted by using a comparator.

    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.

    Parameters

    • Optional comparator: function
        • (valueA: V, valueB: V): number
        • Parameters

          • valueA: V
          • valueB: V

          Returns number

    Returns Iterable<K, V>

sortBy

  • sortBy<C>(comparatorValueMapper: function, comparator?: function): Iterable<K, V>
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

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

    Type parameters

    • C

    Parameters

    • comparatorValueMapper: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): C
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns C

    • Optional comparator: function
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns Iterable<K, V>

take

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeLast

  • takeLast(amount: number): Iterable<K, V>
  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns Iterable<K, V>

takeUntil

  • takeUntil(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns false.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

takeWhile

  • takeWhile(predicate: function, context?: any): Iterable<K, V>
  • Returns a new Iterable of the same type which includes entries from this Iterable as long as the predicate returns true.

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

    Parameters

    • predicate: function
        • (value?: V, key?: K, iter?: Iterable<K, V>): boolean
        • Parameters

          • Optional value: V
          • Optional key: K
          • Optional iter: Iterable<K, V>

          Returns boolean

    • Optional context: any

    Returns Iterable<K, V>

toArray

  • toArray(): Array<V>
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns Array<V>

toIndexedSeq

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

    Returns Indexed<V>

toJS

  • toJS(): any
  • Deeply converts this Iterable to equivalent JS.

    Iterable.Indexeds, and Iterable.Sets become Arrays, while Iterable.Keyeds become Objects.

    alias

    toJSON

    Returns any

toKeyedSeq

  • toKeyedSeq(): Keyed<K, V>
  • Returns a Seq.Keyed from this Iterable where indices are treated as keys.

    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 Keyed<K, V>

toList

  • Converts this Iterable to a List, discarding keys.

    Note: This is equivalent to List(this), but provided to allow for chained expressions.

    Returns List<V>

toMap

  • toMap(): Map<K, V>
  • Converts this Iterable to a Map, Throws if keys are not hashable.

    Note: This is equivalent to Map(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns Map<K, V>

toObject

  • toObject(): object
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns object

    • [key: string]: V

toOrderedMap

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

    Note: This is equivalent to OrderedMap(this.toKeyedSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedMap<K, V>

toOrderedSet

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

    Note: This is equivalent to OrderedSet(this.valueSeq()), but provided for convenience and to allow for chained expressions.

    Returns OrderedSet<V>

toSeq

  • toSeq(): Seq<K, V>
  • Converts this Iterable to a Seq of the same kind (indexed, keyed, or set).

    Returns Seq<K, V>

toSet

  • toSet(): Set<V>
  • Converts this Iterable to a Set, discarding keys. Throws if values are not hashable.

    Note: This is equivalent to Set(this), but provided to allow for chained expressions.

    Returns Set<V>

toSetSeq

  • toSetSeq(): Set<V>
  • Returns a Seq.Set of the values of this Iterable, discarding keys.

    Returns Set<V>

toStack

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

    Note: This is equivalent to Stack(this), but provided to allow for chained expressions.

    Returns Stack<V>

valueSeq

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

    Returns Indexed<V>

values

  • An iterator of this Iterable's 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.

    Returns Iterator<V>

Set

  • Set<T>(): Set<T>
  • Set<T>(iter: Set<T>): Set<T>
  • Set<T>(iter: Indexed<T>): Set<T>
  • Set<K, V>(iter: 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>
  • Create a new immutable Set containing the values of the provided iterable-like.

    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.

    Type parameters

    • T

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Set<any>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • A Collection of unique values with O(log32 N) adds and has.

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Set<T>

Collection

Collection:

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

Implementations should extend one of the subclasses, Collection.Keyed, Collection.Indexed, or Collection.Set.

Indexed

Indexed:

Collection which represents ordered indexed values.

Indexed

Indexed:

Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

Keyed

Keyed:

Collection which represents key-value pairs.

Keyed

Keyed:

Keyed Iterables have discrete keys tied to each value.

When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

Set:

Collection which represents values, unassociated with keys or indices.

Collection.Set implementations should guarantee value uniqueness.

Set

Set:

Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

var seq = Seq.Set.of('A', 'B', 'C');
assert.equal(seq.every((v, k) => v === k), true);

fromKeys

  • fromKeys<T>(iter: Iterable<T, any>): Set<T>
  • fromKeys(obj: object): Set<string>
  • Set.fromKeys() creates a new immutable Set containing the keys from this Iterable or JavaScript Object.

    Type parameters

    • T

    Parameters

    Returns Set<T>

  • Parameters

    • obj: object
      • [key: string]: any

    Returns Set<string>

isSet

  • isSet(maybeSet: any): boolean
  • True if the provided value is a Set

    Parameters

    • maybeSet: any

    Returns boolean

of

  • of<T>(...values: T[]): Set<T>
  • Creates a new Set containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Set<T>

add

  • add(value: T): Set<T>
  • Returns a new Set which also includes this value.

    Parameters

    • value: T

    Returns Set<T>

asImmutable

  • asImmutable(): Set<T>
  • see

    Map#asImmutable

    Returns Set<T>

asMutable

  • asMutable(): Set<T>
  • see

    Map#asMutable

    Returns Set<T>

clear

  • clear(): Set<T>
  • Returns a new Set containing no values.

    Returns Set<T>

delete

  • delete(value: T): Set<T>
  • Returns a new Set which excludes this value.

    Note: delete cannot be safely used in IE8

    alias

    remove

    Parameters

    • value: T

    Returns Set<T>

intersect

  • intersect(...iterables: Iterable<any, T>[]): Set<T>
  • intersect(...iterables: Array<T>[]): Set<T>
  • Returns a Set which has removed any values not also contained within iterables.

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

merge

  • merge(...iterables: Iterable<any, T>[]): Set<T>
  • merge(...iterables: Array<T>[]): Set<T>
  • Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

remove

  • remove(value: T): Set<T>
  • Parameters

    • value: T

    Returns Set<T>

subtract

  • subtract(...iterables: Iterable<any, T>[]): Set<T>
  • subtract(...iterables: Array<T>[]): Set<T>
  • Returns a Set excluding any values contained within iterables.

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

union

  • union(...iterables: Iterable<any, T>[]): Set<T>
  • union(...iterables: Array<T>[]): Set<T>
  • Returns a Set including any value from iterables that does not already exist in this Set.

    alias

    merge

    Parameters

    Returns Set<T>

  • Parameters

    • Rest ...iterables: Array<T>[]

    Returns Set<T>

withMutations

  • withMutations(mutator: function): Set<T>
  • Note: Not all methods can be used on a mutable collection or within withMutations! Only add may be used mutatively.

    see

    Map#withMutations

    Parameters

    • mutator: function
        • (mutable: Set<T>): any
        • Parameters

          • mutable: Set<T>

          Returns any

    Returns Set<T>

Stack

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

    The iteration order of the provided iterable is preserved in the resulting Stack.

    Type parameters

    • T

    Returns Stack<T>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • T

    Parameters

    Returns Stack<T>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • T

    Parameters

    Returns Stack<T>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • K

    • V

    Parameters

    Returns Stack<any>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • T

    Parameters

    • array: Array<T>

    Returns Stack<T>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • T

    Parameters

    Returns Stack<T>

  • Stacks are indexed collections which support very efficient O(1) addition and removal from the front using unshift(v) and shift().

    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.

    Type parameters

    • T

    Parameters

    • iterable: Object

    Returns Stack<T>

Collection

Collection:

Collection is the abstract base class for concrete data structures. It cannot be constructed directly.

Implementations should extend one of the subclasses, Collection.Keyed, Collection.Indexed, or Collection.Set.

Indexed

Indexed:

Collection which represents ordered indexed values.

Keyed

Keyed:

Collection which represents key-value pairs.

Keyed

Keyed:

Keyed Iterables have discrete keys tied to each value.

When iterating Iterable.Keyed, each iteration will yield a [K, V] tuple, in other words, Iterable#entries is the default iterator for Keyed Iterables.

toSeq

  • Returns Seq.Keyed.

    override

    Returns Keyed<K, V>

Set

Set:

Collection which represents values, unassociated with keys or indices.

Collection.Set implementations should guarantee value uniqueness.

Set

Set:

Set Iterables only represent values. They have no associated keys or indices. Duplicate values are possible in Seq.Sets, however the concrete Set does not allow duplicate values.

Iterable methods on Iterable.Set such as map and forEach will provide the value as both the first and second arguments to the provided function.

var seq = Seq.Set.of('A', 'B', 'C');
assert.equal(seq.every((v, k) => v === k), true);

toSeq

  • toSeq(): Set<T>
  • Returns Seq.Set.

    override

    Returns Set<T>

Indexed

Indexed:

Indexed Iterables have incrementing numeric keys. They exhibit slightly different behavior than Iterable.Keyed for some methods in order to better mirror the behavior of JavaScript's Array, and add methods which do not make sense on non-indexed Iterables such as indexOf.

Unlike JavaScript arrays, Iterable.Indexeds are always dense. "Unset" indices and undefined indices are indistinguishable, and all indices from 0 to size are visited when iterated.

All Iterable.Indexed methods return re-indexed Iterables. In other words, indices always start at 0 and increment until size. If you wish to preserve indices, using them as keys, convert to a Iterable.Keyed by calling toKeyedSeq.

isStack

  • isStack(maybeStack: any): boolean
  • True if the provided value is a Stack

    Parameters

    • maybeStack: any

    Returns boolean

of

  • of<T>(...values: T[]): Stack<T>
  • Creates a new Stack containing values.

    Type parameters

    • T

    Parameters

    • Rest ...values: T[]

    Returns Stack<T>

asImmutable

  • asImmutable(): Stack<T>
  • see

    Map#asImmutable

    Returns Stack<T>

asMutable

  • see

    Map#asMutable

    Returns Stack<T>

clear

  • Returns a new Stack with 0 size and no values.

    Returns Stack<T>

peek

  • peek(): T
  • Alias for Stack.first().

    Returns T

pop

  • Alias for Stack#shift and is not equivalent to List#pop.

    Returns Stack<T>

push

  • push(...values: T[]): Stack<T>
  • Alias for Stack#unshift and is not equivalent to List#push.

    Parameters

    • Rest ...values: T[]

    Returns Stack<T>

pushAll

  • Alias for Stack#unshiftAll.

    Parameters

    Returns Stack<T>

  • Parameters

    • iter: Array<T>

    Returns Stack<T>

shift

  • 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.

    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.

    Returns Stack<T>

toSeq

  • Returns Seq.Indexed.

    override

    Returns Indexed<T>

unshift

  • unshift(...values: T[]): Stack<T>
  • Returns a new Stack with the provided values prepended, shifting other values ahead to higher indices.

    This is very efficient for Stack.

    Parameters

    • Rest ...values: T[]

    Returns Stack<T>

unshiftAll

  • Like Stack#unshift, but accepts a iterable rather than varargs.

    Parameters

    Returns Stack<T>

  • Parameters

    • iter: Array<T>

    Returns Stack<T>

withMutations

  • withMutations(mutator: function): 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.

    see

    Map#withMutations

    Parameters

    • mutator: function
        • (mutable: Stack<T>): any
        • Parameters

          Returns any

    Returns Stack<T>

Iterator

Iterator:

ES6 Iterator.

This is not part of the Immutable library, but a common interface used by many types in ES6 JavaScript.

ignore

next

  • next(): object
  • Returns object

    • done: boolean
    • value: T

Range

  • Range(start?: number, end?: number, step?: number): Indexed<number>
  • 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() // [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) // []
    

    Parameters

    • Optional start: number
    • Optional end: number
    • Optional step: number

    Returns Indexed<number>

Repeat

  • Repeat<T>(value: T, times?: number): Indexed<T>
  • Returns a Seq.Indexed of value repeated times times. When times is not defined, returns an infinite Seq of value.

    Repeat('foo') // ['foo','foo','foo',...]
    Repeat('bar',4) // ['bar','bar','bar','bar']
    

    Type parameters

    • T

    Parameters

    • value: T
    • Optional times: number

    Returns Indexed<T>

fromJS

  • fromJS(json: any, reviver?: function): any
  • Deeply converts plain JS objects and arrays to Immutable Maps and Lists.

    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"
    

    Parameters

    • json: any
    • Optional reviver: function
        • Parameters

          Returns any

    Returns any

is

  • is(first: any, second: any): boolean
  • Value equality check with semantics similar to Object.is, but treats Immutable Iterables as values, equal if the second Iterable includes equivalent values.

    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.

    Parameters

    • first: any
    • second: any

    Returns boolean