Type Parameters
Hierarchy
Properties
Methods
Returns a new Set which also includes this value.
Note:
addcan be used inwithMutations.Parameters
valueTReturns
this
Returns
thisSee 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 inwithMutations.Returns
thisSee 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:
clearcan be used inwithMutations.Returns
this
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
Seqif necessary.If
predicateis provided, then this returns the count of entries in the Collection for which thepredicatereturns true.Returns
number
Returns a new Set which excludes this value.
Note:
deletecan be used inwithMutations.Note:
deletecannot be safely used in IE8, useremoveif supporting old browsers.
- filter<F>(
predicate: (value: T, key: T, iter: this) => value is F,
context?: unknown,
): NutrientViewer.Immutable.Set<F>Returns a new Set with only the values for which the
predicatefunction returns true.Note:
filter()always returns a new instance, even if it results in not filtering out any values.
Returns a new Collection of the same type with only the entries for which the
predicatefunction returns false.Note:
filterNot()always returns a new instance, even if it results in not filtering out any values.
Returns
T | undefined
Flattens nested Collections.
Will deeply flatten the Collection by default, returning a Collection of the same type, but a
depthcan 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
depthnumberOptionalReturns
Collection<unknown, unknown>Parameters
shallowbooleanOptionalReturns
Collection<unknown, unknown>
The
sideEffectis executed for every entry in the Collection.Unlike
Array#forEach, if any call ofsideEffectreturnsfalse, the iteration will stop. Returns the number of entries iterated (including the last iteration which returned false).
True if a value exists within this
Collection, usingImmutable.isto determine equality
Returns true if this Collection includes no values.
For some lazy
Seq,isEmptymight need to iterate to determine emptiness. At most one iteration will occur.Returns
boolean
Joins values together as a string, inserting a separator between each. The default separator is
",".Parameters
separatorstringOptionalReturns
string
An iterator of this
Collection's keys.Note: this will return an ES6 iterator which does not support Immutable.js sequence algorithms. Use
keySeqinstead, 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>
Returns
T | undefined
Returns the maximum value in this collection. If any values are comparatively equivalent, the first one found will be returned.
The
comparatoris used in the same way asCollection#sort. If it is not provided, the default comparator is>.When two values are considered equivalent, the first encountered will be returned. Otherwise,
maxwill 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
comparatorreturns 0 and either value is NaN, undefined, or null, that value will be returned.
Returns the minimum value in this collection. If any values are comparatively equivalent, the first one found will be returned.
The
comparatoris used in the same way asCollection#sort. If it is not provided, the default comparator is<.When two values are considered equivalent, the first encountered will be returned. Otherwise,
minwill 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
comparatorreturns 0 and either value is NaN, undefined, or null, that value will be returned.
Reduces the Collection to a value by calling the
reducerfor every entry in the Collection and passing along the reduced value.If
initialReductionis not provided, the first item in the Collection will be used.
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 first
amountentries from this Collection.Parameters
amountnumberReturns
this
Returns a new Collection of the same type which excludes the last
amountentries from this Collection.Parameters
amountnumberReturns
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
beginnumberOptionalendnumberOptionalReturns
this
Returns an OrderedSet of the same type which includes the same entries, stably sorted by using a
comparator.If a
comparatoris not provided, a default comparator uses<and>.comparator(valueA, valueB):- Returns
0if the elements should not be swapped. - Returns
-1(or any negative number) ifvalueAcomes beforevalueB - Returns
1(or any positive number) ifvalueAcomes aftervalueB - Alternatively, can return a value of the
PairSortingenum 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
Returns
- Returns
- sortBy<C>(
comparatorValueMapper: (value: T, key: T, iter: this) => C,
comparator?: (valueA: C, valueB: C) => number,
): NutrientViewer.Immutable.Set<T> & OrderedSet<T>Like
sort, but also accepts acomparatorValueMapperwhich 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.
Returns a new Collection of the same type which includes the first
amountentries from this Collection.Parameters
amountnumberReturns
this
Returns a new Collection of the same type which includes the last
amountentries from this Collection.Parameters
amountnumberReturns
this
Returns an Seq.Indexed of the values of this Collection, discarding keys.
Returns
Indexed<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 onMapor other keyed collections,collection.toList()discards the keys and creates a list of only the values, whereasList(collection)creates a list of entry tuples.Returns
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
OrderedMap<T, T>
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
An iterator of this
Collection's values.Note: this will return an ES6 iterator which does not support Immutable.js sequence algorithms. Use
valueSeqinstead, 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
booleanSee 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 inwithMutations.Parameters
mutator(mutable: this) => unknownReturns
thisSee 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
otherunknownReturns
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
undefinedvalue, so ifnotSetValueis not provided and this method returnsundefined, that does not guarantee the key was not found.
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>notSetValueunknownOptionalReturns
unknown
True if a key exists within this
Collection, usingImmutable.isto determine equalityParameters
keyTReturns
boolean
Computes and returns the hashed identity for this Collection.
The
hashCodeof a Collection is used to determine potential equality, and is used when adding this to aSetor as a key in aMap, enabling lookup via a different instance.If two values have the same
hashCode, they are not guaranteed to be equal. If two values have differenthashCodes, 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 }
The number of items in this Set.