-
Notifications
You must be signed in to change notification settings - Fork 1
StdLib Map Set
Roger Johansson edited this page Jan 14, 2026
·
1 revision
Collection types for storing key-value pairs and unique values.
Implementation Status: 100% Complete
| Type | Methods | Implemented |
|---|---|---|
| Map | 13 | 13 |
| Set | 18 | 18 |
| WeakMap | 5 | 5 |
| WeakSet | 4 | 4 |
| Total | 40 | 40 |
A collection of key-value pairs with any key type.
| Method | Status | Description |
|---|---|---|
Map.groupBy(items, callback) |
Implemented | Groups by callback key (ES2024) |
Map[Symbol.species] |
Implemented | Returns constructor |
| Method | Status | Description |
|---|---|---|
set(key, value) |
Implemented | Adds/updates entry, returns Map |
get(key) |
Implemented | Returns value or undefined |
has(key) |
Implemented | Checks if key exists |
delete(key) |
Implemented | Removes entry, returns boolean |
clear() |
Implemented | Removes all entries |
forEach(callback, thisArg) |
Implemented | Iterates entries |
entries() |
Implemented | Returns [key, value] iterator |
keys() |
Implemented | Returns key iterator |
values() |
Implemented | Returns value iterator |
size (getter) |
Implemented | Returns entry count |
[Symbol.iterator] |
Implemented | Alias for entries() |
A collection of unique values.
| Method | Status | Description |
|---|---|---|
Set[Symbol.species] |
Implemented | Returns constructor |
| Method | Status | Description |
|---|---|---|
add(value) |
Implemented | Adds value, returns Set |
has(value) |
Implemented | Checks if value exists |
delete(value) |
Implemented | Removes value, returns boolean |
clear() |
Implemented | Removes all values |
forEach(callback, thisArg) |
Implemented | Iterates values |
entries() |
Implemented | Returns [value, value] iterator |
keys() |
Implemented | Alias for values() |
values() |
Implemented | Returns value iterator |
size (getter) |
Implemented | Returns value count |
[Symbol.iterator] |
Implemented | Alias for values() |
| Method | Status | Description |
|---|---|---|
union(other) |
Implemented | Returns new Set combining both |
intersection(other) |
Implemented | Returns common elements |
difference(other) |
Implemented | Returns elements not in other |
symmetricDifference(other) |
Implemented | Returns exclusive elements |
isSubsetOf(other) |
Implemented | Checks if all elements in other |
isSupersetOf(other) |
Implemented | Checks if contains all of other |
isDisjointFrom(other) |
Implemented | Checks for no common elements |
A Map with weakly held object keys (allows garbage collection).
| Method | Status | Description |
|---|---|---|
set(key, value) |
Implemented | Key must be object |
get(key) |
Implemented | Returns value or undefined |
has(key) |
Implemented | Checks if key exists |
delete(key) |
Implemented | Removes entry |
- Keys must be objects (no primitives)
- Not iterable (no
forEach,entries, etc.) - No
sizeproperty - Entries auto-removed when key is garbage collected
A Set with weakly held object values.
| Method | Status | Description |
|---|---|---|
add(value) |
Implemented | Value must be object |
has(value) |
Implemented | Checks if value exists |
delete(value) |
Implemented | Removes value |
- Values must be objects (no primitives)
- Not iterable
- No
sizeproperty - Values auto-removed when garbage collected
| Feature | Map/Set | WeakMap/WeakSet |
|---|---|---|
| Key/Value Types | Any | Objects only |
| Enumerable | Yes | No |
size property |
Yes | No |
| Prevents GC | Yes | No |
| Use Case | General storage | Metadata on objects |
Map and Set use SameValueZero for key/value comparison:
-
NaN === NaNis true -
+0 === -0is true
Map and Set maintain insertion order during iteration.
WeakMap and WeakSet use .NET's ConditionalWeakTable internally.
| File | Purpose |
|---|---|
StdLib/MapSet/MapConstructor.cs |
Map constructor |
StdLib/MapSet/MapPrototype.cs |
Map prototype |
StdLib/MapSet/SetConstructor.cs |
Set constructor |
StdLib/MapSet/SetPrototype.cs |
Set prototype |
StdLib/MapSet/WeakMapConstructor.cs |
WeakMap constructor |
StdLib/MapSet/WeakMapPrototype.cs |
WeakMap prototype |
StdLib/MapSet/WeakSetConstructor.cs |
WeakSet constructor |
StdLib/MapSet/WeakSetPrototype.cs |
WeakSet prototype |
JsTypes/JsMap.cs |
Map implementation |
JsTypes/JsSet.cs |
Set implementation |
JsTypes/JsWeakMap.cs |
WeakMap implementation |
JsTypes/JsWeakSet.cs |
WeakSet implementation |
- WeakCollections - Deep dive into weak references
- Iterator-Protocol - Collection iteration