Create a new immutable OrderedSet containing the values of the provided collection-like.
Note: OrderedSet
is a factory function and not a class, and does not use
the new
keyword during construction.
A type of Set that has the additional guarantee that the iteration order of
values will be the order in which they were add
ed.
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.
A type of Set that has the additional guarantee that the iteration order of
values will be the order in which they were add
ed.
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.
The number of items in this OrderedSet.
True if the provided value is an OrderedSet.
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.
Similar to Collection()
, but always returns a Collection.Set.
Note: Collection.Set
is a factory 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 OrderedSet 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.
Flat-maps the OrderedSet, returning a new OrderedSet.
Similar to set.map(...).flatten(true)
.
Set.fromKeys()
creates a new immutable Set containing the keys from
this Collection or JavaScript Object.
OrderedSet.fromKeys()
creates a new immutable OrderedSet containing
the keys from this Collection or JavaScript Object.
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"" ]
True if the provided value is a Set
Returns a new Set with values passed through a
mapper
function.
OrderedSet([ 1, 2 ]).map(x => 10 * x)
// OrderedSet [10, 20]
Creates a new Set containing values
.
Creates a new OrderedSet containing values
.
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
.
Returns an OrderedSet including any value from collections
that does
not already exist in this OrderedSet.
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
.
Returns an OrderedSet of the same type "zipped" with the provided collections.
Like zipWith
, but using the default zipper
: creating an Array
.
const a = OrderedSet([ 1, 2, 3 ])
const b = OrderedSet([ 4, 5, 6 ])
const c = a.zip(b)
// OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
Returns a OrderedSet of the same type "zipped" with the provided collections.
Unlike zip
, zipAll
continues zipping until the longest collection is
exhausted. Missing values from shorter collections are filled with undefined
.
const a = OrderedSet([ 1, 2 ]);
const b = OrderedSet([ 3, 4, 5 ]);
const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
Note: Since zipAll will return a collection as large as the largest input, some results may contain undefined values. TypeScript cannot account for these without cases (as of v2.5).
Returns an OrderedSet of the same type "zipped" with the provided
collections by using a custom zipper
function.
Generated using TypeDoc
A type of Set that has the additional guarantee that the iteration order of values will be the order in which they were
add
ed.The iteration behavior of OrderedSet is the same as native ES6 Set.
Note that
OrderedSet
are more expensive than non-orderedSet
and may consume more memory.OrderedSet#add
is amortized O(log32 N), but not stable.