@hyperfrontend/immutable-api-utils/built-in-copy/weak-map

weak-map

Locked, prototype-pollution-resistant copy of the global WeakMap constructor.

The WeakMap constructor is wrapped in a createWeakMap factory at module-load time and frozen into a tamper-proof namespace, so private-state storage keeps working even if the global WeakMap is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.

API Reference

ƒ Functions

§function

createWeakMap<K, V>(iterable?: Iterable<unknown, any, any>): WeakMap<K, V>

(Safe copy) Creates a new WeakMap using the captured WeakMap constructor. Use this instead of new WeakMap().

Parameters

NameTypeDescription
§iterable?
Iterable<unknown, any, any>
Optional iterable of key-value pairs.

Returns

WeakMap<K, V>
A new WeakMap instance.

Variables

§type

WeakMap

(Safe copy) Namespace object containing WeakMap factory. Note: Importing this imports all methods in this namespace (no tree-shaking).