Skip to main content

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

ParameterType
mainSetSet<T>
...setsToAddreadonly ReadonlySet<T>[]

Returns

void

Defined in

functions/set.ts:14


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

ParameterType
...setsreadonly ReadonlySet<T>[]

Returns

Set<T>

Defined in

functions/set.ts:32


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

ParameterType
oldSetReadonlySet<T>

Returns

Set<T>

Defined in

functions/set.ts:45


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

ParameterType
objectRecord<K, V>

Returns

ReadonlySet<K>

Defined in

functions/set.ts:59


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

ParameterType
objectRecord<K, V>

Returns

Set<K>

Defined in

functions/set.ts:71


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

ParameterType
objectRecord<K, V>

Returns

ReadonlySet<V>

Defined in

functions/set.ts:88


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

ParameterType
objectRecord<K, V>

Returns

Set<V>

Defined in

functions/set.ts:101


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

ParameterType
setSet<T>
...elementsreadonly T[]

Returns

void

Defined in

functions/set.ts:120


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

ParameterType
setReadonlySet<T>
...elementsreadonly T[]

Returns

boolean

Defined in

functions/set.ts:133