Create a new immutable Set containing the values of the provided collection-like.
Note: Set is a factory function and not a class, and does not use the
new keyword during construction.
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.
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.
The number of items in this Set.
Set.fromKeys() creates a new immutable Set containing the keys from
this Collection or JavaScript Object.
True if the provided value is a Set
Creates a new Set containing values.
Creates a Collection.
The type of Collection created is based on the input.
Collection, that same Collection.Collection.Indexed.Collection.Indexed.Collection.Keyed.This methods forces the conversion of Objects and Strings to Collections.
If you want to ensure that a Collection of one item is returned, use
Seq.of.
Note: An Iterator itself will be treated as an object, becoming a Seq.Keyed,
which is usually not what you want. You should turn your Iterator Object into
an iterable object by defining a Symbol.iterator (or @@iterator) method which
returns this.
Note: Collection is a conversion function and not a class, and does not
use the new keyword during construction.
Returns a new Set which also includes this value.
Note: add can be used in withMutations.
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 a new Set containing no values.
Note: clear can be used in withMutations.
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.
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.
Returns a Set which has removed any values not also contained
within collections.
Note: intersect can be used in withMutations.
Set.intersect() creates a new immutable Set that is the intersection of
a collection of other sets.
const { Set } = require('immutable')
const intersected = Set.intersect([
Set([ 'a', 'b', 'c' ])
Set([ 'c', 'a', 't' ])
])
// Set [ "a", "c"" ]
Returns a new Set with values passed through a
mapper function.
Set([1,2]).map(x => 10 * x)
// Set [10,20]
Returns a Set excluding any values contained within collections.
const { OrderedSet } = require('immutable')
OrderedSet([ 1, 2, 3 ]).subtract([1, 3])
// OrderedSet [2]
Note: subtract can be used in withMutations.
Shallowly converts this collection to an Array.
Deeply converts this Set collection to equivalent native JavaScript Array.
Shallowly converts this Set collection to equivalent native JavaScript Array.
Returns Seq.Set.
Returns a Set including any value from collections that does not already
exist in this Set.
Note: union can be used in withMutations.
Set.union() creates a new immutable Set that is the union of a
collection of other sets.
const { Set } = require('immutable')
const unioned = Set.union([
Set([ 'a', 'b', 'c' ])
Set([ 'c', 'a', 't' ])
])
// Set [ "a", "b", "c", "t"" ]
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.
Generated using TypeDoc
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.