Const// Accepts both Map and WeakMap
AnyMapSchema.parse(new Map([['key', 'value']])); // ✓ passes
AnyMapSchema.parse(new WeakMap([[obj, 'value']])); // ✓ passes
AnyMapSchema.parse(new Set()); // ✗ fails (wrong collection type)
// Usage in assertions
expect(myWeakMap, 'to have key', someObject); // Works with WeakMap
expect(myMap, 'to have key', 'stringKey'); // Works with Map
expect(myWeakMap, 'to have size', 3); // ✗ Fails - WeakMap has no size
Schema that matches either
MaporWeakMapinstances.This union schema accommodates both strong and weak Map variants, enabling assertions to work polymorphically across both collection types. The choice between Map and WeakMap affects memory management and iteration capabilities but often doesn't impact structural validation logic.
Key Differences Between Map and WeakMap:
.size.sizeUsage Considerations:
Memory Management Implications: