Nutrient Web SDK

Interface Set

Interface

Type Parameters

T

Hierarchy

SetSet

Properties

size

Readonly
number

The number of items in this Set.

Methods

  • Returns a new Set which also includes this value.

    Note: add can be used in withMutations.

    Parameters

    valueT

    Returns

    this
  • Returns

    this

    See Also

    • Map#asImmutable

  • Note: Not all methods can be used on a mutable collection or within withMutations! Check the documentation for each method to see if it mentions being safe to use in withMutations.

    Returns

    this

    See Also

    • Map#asMutable

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

    Returns

    this
  • Returns a new Set containing no values.

    Note: clear can be used in withMutations.

    Returns

    this
  • Parameters

    valueT

    Returns

    boolean
  • Returns the size of this Collection.

    Regardless of if this Collection 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 Collection for which the predicate returns true.

    Returns

    number
  • Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    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

    grouper(value: T, key: T, iter: this) => G
    contextunknown
    Optional

    Returns

    Map<G, number>
  • Returns a new Set which excludes this value.

    Note: delete can be used in withMutations.

    Note: delete cannot be safely used in IE8, use remove if supporting old browsers.

    Parameters

    valueT

    Returns

    this
  • An iterator of this Collection'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

    IterableIterator<[T, T]>
  • Returns a new Seq.Indexed of [key, value] tuples.

    Returns

    Indexed<[T, T]>
  • True if predicate returns true for all entries in the Collection.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    boolean
  • Returns a new Set with only the values for which the predicate function returns true.

    Note: filter() always returns a new instance, even if it results in not filtering out any values.

    Type Parameters

    F

    Parameters

    predicate(value: T, key: T, iter: this) => value is F
    contextunknown
    Optional
  • Returns a new Collection with only the values for which the predicate function returns true.

    Note: filter() always returns a new instance, even if it results in not filtering out any values.

    Parameters

    predicate(value: T, key: T, iter: this) => unknown
    contextunknown
    Optional

    Returns

    this
  • Returns a new Collection of the same type with only the entries for which the predicate function returns false.

    Note: filterNot() always returns a new instance, even if it results in not filtering out any values.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    this
  • Returns the first value for which the predicate returns true.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional
    notSetValueT
    Optional

    Returns

    T | undefined
  • Returns the first [key, value] entry for which the predicate returns true.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional
    notSetValueT
    Optional

    Returns

    [T, T] | undefined
  • Returns the key for which the predicate returns true.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    T | undefined
  • 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: this) => boolean
    contextunknown
    Optional
    notSetValueT
    Optional

    Returns

    T | undefined
  • 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: this) => boolean
    contextunknown
    Optional
    notSetValueT
    Optional

    Returns

    [T, T] | undefined
  • 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: this) => boolean
    contextunknown
    Optional

    Returns

    T | undefined
  • In case the Collection is not empty returns the first element of the Collection. In case the Collection is empty returns the optional default value if provided, if no default value is provided returns undefined.

    Type Parameters

    NSV

    Parameters

    notSetValueNSV

    Returns

    T | NSV
  • Returns

    T | undefined
  • Flattens nested Collections.

    Will deeply flatten the Collection by default, returning a Collection 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 Collection, not Arrays or Objects.

    Note: flatten(true) operates on Collection<unknown, Collection<K, V>> and returns Collection<K, V>

    Parameters

    depthnumber
    Optional

    Returns

    Collection<unknown, unknown>
  • Parameters

    shallowboolean
    Optional

    Returns

    Collection<unknown, unknown>
  • The sideEffect is executed for every entry in the Collection.

    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(value: T, key: T, iter: this) => unknown
    contextunknown
    Optional

    Returns

    number
  • Returns a Map of Collection, grouped by the return value of the grouper function.

    Note: This is always an eager operation.

    Type Parameters

    G

    Parameters

    grouper(value: T, key: T, iter: this) => G
    contextunknown
    Optional
  • True if a value exists within this Collection, using Immutable.is to determine equality

    Parameters

    valueT

    Returns

    boolean
  • Returns a Set which has removed any values not also contained within collections.

    Note: intersect can be used in withMutations.

    Parameters

    ...collectionsIterable<T, any, any>[]

    Returns

    this
  • Returns true if this Collection 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 Collection.

    Parameters

    iterIterable<T>

    Returns

    boolean
  • True if this Collection includes every value in iter.

    Parameters

    iterIterable<T>

    Returns

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

    Parameters

    separatorstring
    Optional

    Returns

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

    Parameters

    searchValueT

    Returns

    T | undefined
  • An iterator of this Collection'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

    IterableIterator<T>
  • Returns a new Seq.Indexed of the keys of this Collection, discarding values.

    Returns

    Indexed<T>
  • In case the Collection is not empty returns the last element of the Collection. In case the Collection is empty returns the optional default value if provided, if no default value is provided returns undefined.

    Type Parameters

    NSV

    Parameters

    notSetValueNSV

    Returns

    T | NSV
  • Returns

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

    Parameters

    searchValueT

    Returns

    T | undefined
  • Returns a new Set with values passed through a mapper function.

    Set([1,2]).map(x => 10 * x)
    // Set [10,20]
    

    Type Parameters

    M

    Parameters

    mapper(value: T, key: T, iter: this) => M
    contextunknown
    Optional
  • 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 Collection#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

    comparatorComparator<T>
    Optional

    Returns

    T | undefined
  • Like max, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

    Type Parameters

    C

    Parameters

    comparatorValueMapper(value: T, key: T, iter: this) => C
    comparatorComparator<C>
    Optional

    Returns

    T | undefined
  • 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 Collection#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

    comparatorComparator<T>
    Optional

    Returns

    T | undefined
  • Like min, but also accepts a comparatorValueMapper which allows for comparing by more sophisticated means:

    Type Parameters

    C

    Parameters

    comparatorValueMapper(value: T, key: T, iter: this) => C
    comparatorComparator<C>
    Optional

    Returns

    T | undefined
  • Reduces the Collection to a value by calling the reducer for every entry in the Collection and passing along the reduced value.

    If initialReduction is not provided, the first item in the Collection will be used.

    Parameters

    reducer(reduction: T, value: T, key: T, iter: this) => T

    Returns

    See Also

    • Array#reduce.

  • Type Parameters

    R

    Parameters

    reducer(reduction: R, value: T, key: T, iter: this) => R
    initialReductionR
    contextunknown
    Optional

    Returns

  • Type Parameters

    R

    Parameters

    reducer(reduction: T | R, value: T, key: T, iter: this) => R

    Returns

  • Reduces the Collection in reverse (from the right side).

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

    Parameters

    reducer(reduction: T, value: T, key: T, iter: this) => T

    Returns

  • Type Parameters

    R

    Parameters

    reducer(reduction: R, value: T, key: T, iter: this) => R
    initialReductionR
    contextunknown
    Optional

    Returns

  • Type Parameters

    R

    Parameters

    reducer(reduction: T | R, value: T, key: T, iter: this) => R

    Returns

  • Parameters

    valueT

    Returns

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

    Returns

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

    Returns

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

    Parameters

    amountnumber

    Returns

    this
  • Returns a new Collection of the same type which includes entries starting from when predicate first returns true.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    this
  • Returns a new Collection of the same type which includes entries starting from when predicate first returns false.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

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

    If begin is negative, it is offset from the end of the Collection. e.g. slice(-2) returns a Collection of the last two entries. If it is not provided the new Collection will begin at the beginning of this Collection.

    If end is negative, it is offset from the end of the Collection. e.g. slice(0, -1) returns a Collection of everything but the last entry. If it is not provided, the new Collection will continue through the end of this Collection.

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

    Parameters

    beginnumber
    Optional
    endnumber
    Optional

    Returns

    this
  • True if predicate returns true for any entry in the Collection.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    boolean
  • Returns an OrderedSet 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
    • Alternatively, can return a value of the PairSorting enum type
    • Is pure, i.e. it must always return the same value for the same pair of values.

    Note: sort() Always returns a new instance, even if the original was already sorted.

    Note: This is always an eager operation.

    Parameters

    comparatorComparator<T>
    Optional
  • Like sort, but also accepts a comparatorValueMapper which allows for sorting by more sophisticated means:

    Note: sortBy() Always returns a new instance, even if the original was already sorted.

    Note: This is always an eager operation.

    Type Parameters

    C

    Parameters

    comparatorValueMapper(value: T, key: T, iter: this) => C
    comparator(valueA: C, valueB: C) => number
    Optional
  • Returns a Set excluding any values contained within collections.

    Note: subtract can be used in withMutations.

    Parameters

    ...collectionsIterable<T, any, any>[]

    Returns

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

    Parameters

    amountnumber

    Returns

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

    Parameters

    amountnumber

    Returns

    this
  • Returns a new Collection of the same type which includes entries from this Collection as long as the predicate returns false.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    this
  • Returns a new Collection of the same type which includes entries from this Collection as long as the predicate returns true.

    Parameters

    predicate(value: T, key: T, iter: this) => boolean
    contextunknown
    Optional

    Returns

    this
  • Shallowly converts this collection to an Array.

    Returns

    T[]
  • Returns an Seq.Indexed of the values of this Collection, discarding keys.

    Returns

    Indexed<T>
  • Returns a Seq.Keyed from this Collection where indices are treated as keys.

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

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

    Returns

    Keyed<T, T>
  • Converts this Collection to a List, discarding keys.

    This is similar to List(collection), but provided to allow for chained expressions. However, when called on Map or other keyed collections, collection.toList() discards the keys and creates a list of only the values, whereas List(collection) creates a list of entry tuples.

  • Converts this Collection 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>
  • Converts this Collection 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

  • Converts this Collection 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

  • Converts this Collection 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 a Seq.Set of the values of this Collection, discarding keys.

    Returns

  • Converts this Collection 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

  • An iterator of this Collection'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

    IterableIterator<T>
  • Returns an Seq.Indexed of the values of this Collection, discarding keys.

    Returns

    Indexed<T>
  • Returns

    boolean

    See Also

    • Map#wasAltered

  • Note: Not all methods can be used on a mutable collection or within withMutations! Check the documentation for each method to see if it mentions being safe to use in withMutations.

    Parameters

    mutator(mutable: this) => unknown

    Returns

    this

    See Also

    • Map#withMutations

Immutable Record API

12
  • Returns

    IterableIterator<T>
  • True if this and the other Collection 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

    otherunknown

    Returns

    boolean
  • Returns the value associated with the provided key, or notSetValue if the Collection 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.

    Type Parameters

    NSV

    Parameters

    keyT
    notSetValueNSV

    Returns

    T | NSV
  • Parameters

    keyT

    Returns

    T | undefined
  • Returns the value found by following a path of keys or indices through nested Collections.

    Plain JavaScript Object or Arrays may be nested within an Immutable.js Collection, and getIn() can access those values as well:

    Parameters

    searchKeyPathIterable<unknown>
    notSetValueunknown
    Optional

    Returns

    unknown
  • True if a key exists within this Collection, using Immutable.is to determine equality

    Parameters

    keyT

    Returns

    boolean
  • Computes and returns the hashed identity for this Collection.

    The hashCode of a Collection 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.

    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
  • True if the result of following a path of keys or indices through nested Collections results in a set value.

    Parameters

    searchKeyPathIterable<unknown>

    Returns

    boolean
  • Deeply converts this Set collection to equivalent native JavaScript Array.

    Returns

    DeepCopy<T>[]
  • Shallowly converts this Set collection to equivalent native JavaScript Array.

    Returns

    T[]
  • Shallowly converts this Collection to an Object.

    Converts keys to Strings.

    Returns

    { [key: string]: T }
  • Returns Seq.Set.

    Returns

  • This can be very useful as a way to "chain" a normal function into a sequence of methods. RxJS calls this "let" and lodash calls it "thru".

    For example, to sum a Seq after mapping and filtering:

    Type Parameters

    R

    Parameters

    updater(value: this) => R

    Returns