BUPKIS
    Preparing search index...

    Variable AnyMapSchemaConst

    AnyMapSchema: ZodUnion<
        [
            ZodCustom<Map<unknown, unknown>, Map<unknown, unknown>>,
            ZodCustom<WeakMap<WeakKey, unknown>, WeakMap<WeakKey, unknown>>,
        ],
    > = ...

    Schema that matches either Map or WeakMap instances.

    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:

    • Map: Strong references, enumerable, iterable, any key types, has .size
    • WeakMap: Weak references, not enumerable, not iterable, object keys only, no .size

    Usage Considerations:

    • Use for assertions that need to work with either Map type
    • Particularly useful in library code that accepts either variant
    • Some Map-specific operations (iteration, size) won't work with WeakMap
    • WeakMap key restrictions (objects/symbols only) should be considered

    Memory Management Implications:

    • Map entries prevent garbage collection of keys
    • WeakMap entries allow garbage collection when keys become unreachable
    • This affects long-lived caches and memory-sensitive applications
    // 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