Skip to content

isSetEqual

Compare two sets for shallow equality

115 bytes
since v12.7.0

Usage

Returns true when two Set instances contain the same values (compared by reference).

import * as
import _
_
from 'radashi'
const
const left: Set<string>
left
= new
var Set: SetConstructor
new <string>(iterable?: Iterable<string> | null | undefined) => Set<string> (+1 overload)
Set
(['a', 'b', 'c'])
const
const right: Set<string>
right
= new
var Set: SetConstructor
new <string>(iterable?: Iterable<string> | null | undefined) => Set<string> (+1 overload)
Set
(['c', 'b', 'a'])
import _
_
.
function isSetEqual(x: Set<any>, y: Set<any>): boolean

Check if two sets are equal.

Note: This does NOT check for deep equality of the items.

isSetEqual
(
const left: Set<string>
left
,
const right: Set<string>
right
) // => true
const
const object: {
id: number;
}
object
= {
id: number
id
: 1 }
import _
_
.
function isSetEqual(x: Set<any>, y: Set<any>): boolean

Check if two sets are equal.

Note: This does NOT check for deep equality of the items.

isSetEqual
(new
var Set: SetConstructor
new <{
id: number;
}>(iterable?: Iterable<{
id: number;
}> | null | undefined) => Set<{
id: number;
}> (+1 overload)
Set
([
const object: {
id: number;
}
object
]), new
var Set: SetConstructor
new <{
id: number;
}>(iterable?: Iterable<{
id: number;
}> | null | undefined) => Set<{
id: number;
}> (+1 overload)
Set
([{
id: number
id
: 1 }])) // => false

Entries are matched using Set#has, so two values are considered equal only if they are the same reference.