Constructor
new DeepSet(valuesopt)
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
values |
Iterable
|
<optional> |
Values to add, in order; duplicates are dropped |
Example
const seen = new DeepSet([{ a: 1 }, { b: 2 }])
seen.has({ a: 1 }) // => true — a different object, same structure
seen.has({ a: 2 }) // => false
seen.add({ b: 2 }).size // => 2 — already present, not added again
[...new DeepSet([{ a: 1 }, { a: 1 }])] // => [{ a: 1 }]
Classes
Members
size
- Source:
Methods
add(value) → {DeepSet}
Adds a value unless one structurally equal to it is already held, in which case the one already here stays and this call changes nothing.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
*
|
The value to add |
has(value) → {boolean}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
*
|
The value to look for |
Returns:
- Type:
-
boolean
True when a structurally equal value is already held