Set
Helper functions that have to do with sets.
Functions
addSetsToSet()
function addSetsToSet<T>(mainSet, ...setsToAdd): void
Helper function to add all of the values in one set to another set. The first set passed will be modified in place.
This function is variadic, meaning that you can specify N sets to add to the first set.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
mainSet | Set <T > |
...setsToAdd | readonly ReadonlySet <T >[] |
Returns
void
Defined in
combineSets()
function combineSets<T>(...sets): Set<T>
Helper function to create a new set that is the composition of two or more sets.
This function is variadic, meaning that you can specify N sets.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
...sets | readonly ReadonlySet <T >[] |
Returns
Set
<T
>
Defined in
copySet()
function copySet<T>(oldSet): Set<T>
Helper function to copy a set. (You can also use a Set constructor to accomplish this task.)
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
oldSet | ReadonlySet <T > |
Returns
Set
<T
>
Defined in
objectKeysToReadonlySet()
function objectKeysToReadonlySet<K, V>(object): ReadonlySet<K>
Helper function to convert the keys of an object to a read-only set.
Also see the objectKeysToSet
function.
Type Parameters
Type Parameter |
---|
K extends string | number | symbol |
V |
Parameters
Parameter | Type |
---|---|
object | Record <K , V > |
Returns
ReadonlySet
<K
>
Defined in
objectKeysToSet()
function objectKeysToSet<K, V>(object): Set<K>
Helper function to convert the keys of an object to a set.
Also see the objectKeysToReadonlySet
function.
Type Parameters
Type Parameter |
---|
K extends string | number | symbol |
V |
Parameters
Parameter | Type |
---|---|
object | Record <K , V > |
Returns
Set
<K
>
Defined in
objectValuesToReadonlySet()
function objectValuesToReadonlySet<K, V>(object): ReadonlySet<V>
Helper function to convert the values of an object to a read-only set.
Also see the objectValuesToSet
function.
Type Parameters
Type Parameter |
---|
K extends string | number | symbol |
V |
Parameters
Parameter | Type |
---|---|
object | Record <K , V > |
Returns
ReadonlySet
<V
>
Defined in
objectValuesToSet()
function objectValuesToSet<K, V>(object): Set<V>
Helper function to convert the values of an object to a set.
Also see the objectValuesToReadonlySet
function.
Type Parameters
Type Parameter |
---|
K extends string | number | symbol |
V |
Parameters
Parameter | Type |
---|---|
object | Record <K , V > |
Returns
Set
<V
>
Defined in
setAdd()
function setAdd<T>(set, ...elements): void
Helper function to add one or more elements to a set at once without having to repeatedly call
the Set.add
method.
This function is variadic, meaning that you can pass as many things as you want to add.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
set | Set <T > |
...elements | readonly T [] |
Returns
void
Defined in
setHas()
function setHas<T>(set, ...elements): boolean
Helper function to check for one or more elements in a set at once without having to repeatedly
call the Set.has
method.
This function is variadic, meaning that you can pass as many things as you want to check for. It will return true if one or more elements are found.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
set | ReadonlySet <T > |
...elements | readonly T [] |
Returns
boolean