Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • T

Hierarchy

Index

Properties

size: number

All collections maintain their current size as an integer.

Methods

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

    Returns <internal>.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 <internal>.Iterable<T, T>

  • contains(value: T): boolean
  • Parameters

    • value: T

    Returns boolean

  • count(): number
  • count(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, 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

    Returns 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

    Returns <internal>.Map<G, number>

  • entries(): Iterator<any[]>
  • 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<any[]>

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

    Returns <internal>.Indexed<any[]>

  • 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(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, context?: any): boolean
  • True if predicate returns true for all entries in the Iterable.

    Parameters

    Returns boolean

  • 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

    Returns <internal>.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

    Returns <internal>.Iterable<T, T>

  • find(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, context?: any, notSetValue?: T): T
  • Returns the first value for which the predicate returns true.

    Parameters

    • predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean
    • Optional context: any
    • Optional notSetValue: T

    Returns T

  • findEntry(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, context?: any, notSetValue?: T): any[]
  • Returns the first [key, value] entry for which the predicate returns true.

    Parameters

    • predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean
    • Optional context: any
    • Optional notSetValue: T

    Returns any[]

  • findKey(predicate: (value?: T, key?: T, iter?: <internal>.Keyed<T, T>) => boolean, context?: any): T
  • Returns the key for which the predicate returns true.

    Parameters

    • predicate: (value?: T, key?: T, iter?: <internal>.Keyed<T, T>) => boolean
        • Parameters

          Returns boolean

    • Optional context: any

    Returns T

  • findLast(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, 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: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean
    • Optional context: any
    • Optional notSetValue: T

    Returns T

  • findLastEntry(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, context?: any, notSetValue?: T): 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: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean
    • Optional context: any
    • Optional notSetValue: T

    Returns any[]

  • findLastKey(predicate: (value?: T, key?: T, iter?: <internal>.Keyed<T, T>) => boolean, context?: any): T
  • Returns the last key for which the predicate returns true.

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

    Parameters

    • predicate: (value?: T, key?: T, iter?: <internal>.Keyed<T, T>) => boolean
        • Parameters

          Returns boolean

    • Optional context: any

    Returns T

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

    Returns T

  • 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<any, Iterable<K, V>> and returns Iterable<K, V>

    Parameters

    • Optional depth: number

    Returns <internal>.Iterable<any, any>

  • Parameters

    • Optional shallow: boolean

    Returns <internal>.Iterable<any, any>

  • forEach(sideEffect: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => any, 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

    Returns number

  • 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(searchKeyPath: any[], notSetValue?: any): any
  • getIn(searchKeyPath: <internal>.Iterable<any, any>, notSetValue?: any): any
  • Returns the value found by following a path of keys or indices through nested Iterables.

    Parameters

    • searchKeyPath: any[]
    • Optional notSetValue: any

    Returns any

  • Parameters

    Returns any

  • 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

    Returns <internal>.Keyed<G, <internal>.Iterable<T, T>>

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

    Parameters

    • key: T

    Returns boolean

  • hasIn(searchKeyPath: any[]): boolean
  • hasIn(searchKeyPath: <internal>.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: any[]

    Returns boolean

  • Parameters

    Returns boolean

  • 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(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(): 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

  • True if iter includes every value in this Iterable.

    Parameters

    Returns boolean

  • Parameters

    • iter: T[]

    Returns boolean

  • True if this Iterable includes every value in iter.

    Parameters

    Returns boolean

  • Parameters

    • iter: T[]

    Returns boolean

  • 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(searchValue: T): T
  • Returns the key associated with the search value, or undefined.

    Parameters

    • searchValue: T

    Returns T

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

    Returns <internal>.Indexed<T>

  • keys(): Iterator<T>
  • 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(): T
  • The last value in the Iterable.

    Returns T

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

    Parameters

    • searchValue: T

    Returns T

  • 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

    Returns <internal>.Iterable<T, M>

  • max(comparator?: (valueA: T, valueB: T) => number): 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: (valueA: T, valueB: T) => number
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

  • maxBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => C, comparator?: (valueA: C, valueB: C) => number): 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: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => C
    • Optional comparator: (valueA: C, valueB: C) => number
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

  • min(comparator?: (valueA: T, valueB: T) => number): 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: (valueA: T, valueB: T) => number
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns T

  • minBy<C>(comparatorValueMapper: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => C, comparator?: (valueA: C, valueB: C) => number): 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: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => C
    • Optional comparator: (valueA: C, valueB: C) => number
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns T

  • reduce<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => R, 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: (reduction?: R, value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: T
          • Optional iter: <internal>.Iterable<T, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

  • reduceRight<R>(reducer: (reduction?: R, value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => R, 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: (reduction?: R, value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => R
        • Parameters

          • Optional reduction: R
          • Optional value: T
          • Optional key: T
          • Optional iter: <internal>.Iterable<T, T>

          Returns R

    • Optional initialReduction: R
    • Optional context: any

    Returns R

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

    Returns <internal>.Iterable<T, T>

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

    Returns <internal>.Iterable<T, T>

  • Returns a new Iterable of the same type which excludes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns <internal>.Iterable<T, T>

  • Returns a new Iterable of the same type which excludes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns <internal>.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

    Returns <internal>.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

    Returns <internal>.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 <internal>.Iterable<T, T>

  • some(predicate: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => boolean, context?: any): boolean
  • True if predicate returns true for any entry in the Iterable.

    Parameters

    Returns boolean

  • 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: (valueA: T, valueB: T) => number
        • (valueA: T, valueB: T): number
        • Parameters

          • valueA: T
          • valueB: T

          Returns number

    Returns <internal>.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: (value?: T, key?: T, iter?: <internal>.Iterable<T, T>) => C
    • Optional comparator: (valueA: C, valueB: C) => number
        • (valueA: C, valueB: C): number
        • Parameters

          • valueA: C
          • valueB: C

          Returns number

    Returns <internal>.Iterable<T, T>

  • Returns a new Iterable of the same type which includes the first amount entries from this Iterable.

    Parameters

    • amount: number

    Returns <internal>.Iterable<T, T>

  • Returns a new Iterable of the same type which includes the last amount entries from this Iterable.

    Parameters

    • amount: number

    Returns <internal>.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

    Returns <internal>.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

    Returns <internal>.Iterable<T, T>

  • toArray(): T[]
  • Shallowly converts this iterable to an Array, discarding keys.

    Returns T[]

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

    Returns <internal>.Indexed<T>

  • 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

  • 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 <internal>.Keyed<T, T>

  • Converts this Iterable to a List, discarding keys.

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

    Returns <internal>.List<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 <internal>.Map<T, T>

  • toObject(): {}
  • Shallowly converts this Iterable to an Object.

    Throws if keys are not strings.

    Returns {}

    • [key: string]: V
  • 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 <internal>.OrderedMap<T, T>

  • 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 <internal>.OrderedSet<T>

  • Returns Seq.Set.

    override

    Returns <internal>.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 <internal>.Set<T>

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

    Returns <internal>.Set<T>

  • 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 <internal>.Stack<T>

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

    Returns <internal>.Indexed<T>

  • values(): Iterator<T>
  • 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>

Generated using TypeDoc