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.
Always returns a Seq.Set, discarding associated indices or keys.
Note: Seq.Set is a conversion function and not a class, and does not
use the new keyword during construction.
Set Collections only represent values. They have no associated keys or
indices. Duplicate values are possible in the lazy Seq.Sets, however
the concrete Set Collection does not allow duplicate values.
Collection methods on Collection.Set such as map and forEach will provide
the value as both the first and second arguments to the provided function.
const { Collection } = require('immutable')
const seq = Collection.Set([ 'A', 'B', 'C' ])
// Seq { "A", "B", "C" }
seq.forEach((v, k) =>
assert.equal(v, k)
)
Set Collections only represent values. They have no associated keys or
indices. Duplicate values are possible in the lazy Seq.Sets, however
the concrete Set Collection does not allow duplicate values.
Collection methods on Collection.Set such as map and forEach will provide
the value as both the first and second arguments to the provided function.
const { Collection } = require('immutable')
const seq = Collection.Set([ 'A', 'B', 'C' ])
// Seq { "A", "B", "C" }
seq.forEach((v, k) =>
assert.equal(v, k)
)
Some Seqs can describe their size lazily. When this is the case, size will be an integer. Otherwise it will be undefined.
For example, Seqs returned from map() or reverse()
preserve the size of the original Seq while filter() does not.
Note: Range, Repeat and Seqs made from Arrays and Objects will
always have a size.
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.
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.
Creates a Seq.
Returns a particular kind of Seq based on the input.
Seq, that same Seq.Collection, a Seq of the same kind (Keyed, Indexed, or Set).Seq.Indexed.Seq.Indexed.Seq.Keyed.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: Seq is a conversion function and not a class, and does not use the
new keyword during construction.
Because Sequences are lazy and designed to be chained together, they do
not cache their results. For example, this map function is called a total
of 6 times, as each join iterates the Seq of three values.
var squares = Seq([ 1, 2, 3 ]).map(x => x * x)
squares.join() + squares.join()If you know a Seq will be used multiple times, it may be more
efficient to first cache it in memory. Here, the map function is called
only 3 times.
var squares = Seq([ 1, 2, 3 ]).map(x => x * x).cacheResult()
squares.join() + squares.join()Use this method judiciously, as it must fully evaluate a Seq which can be a burden on memory and possibly performance.
Note: after calling cacheResult, a Seq will always have a size.
Returns a Seq.Set of the provided values
Returns a new Collection with other collections concatenated to this one.
Returns a new Seq with other collections concatenated to this one.
All entries will be present in the resulting Seq, even if they are duplicates.
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.
Returns a new Seq 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 Collection, returning a Collection of the same type.
Similar to collection.map(...).flatten(true).
Flat-maps the Seq, returning a Seq of the same type.
Similar to seq.map(...).flatten(true).
Returns a new Collection.Set with values passed through a
mapper function.
Collection.Set([ 1, 2 ]).map(x => 10 * x)
// Seq { 1, 2 }Note: map() always returns a new instance, even if it produced the
same value at every step.
Returns a new Seq.Set with values passed through a
mapper function.
Seq.Set([ 1, 2 ]).map(x => 10 * x)
// Seq { 10, 20 }
Note: map() always returns a new instance, even if it produced the
same value at every step.
Shallowly converts this collection to an Array.
Shallowly converts this collection to an Array.
Deeply converts this Set collection to equivalent native JavaScript Array.
Deeply converts this Set Seq to equivalent native JavaScript Array.
Shallowly converts this Set collection to equivalent native JavaScript Array.
Shallowly converts this Set Seq to equivalent native JavaScript Array.
Returns Seq.Set.
Returns itself
Generated using TypeDoc
Set Collections only represent values. They have no associated keys or indices. Duplicate values are possible in the lazy
Seq.Sets, however the concreteSetCollection does not allow duplicate values.Collection methods on Collection.Set such as
mapandforEachwill provide the value as both the first and second arguments to the provided function.const { Collection } = require('immutable') const seq = Collection.Set([ 'A', 'B', 'C' ]) // Seq { "A", "B", "C" } seq.forEach((v, k) => assert.equal(v, k) )