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

map

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

The Map constructor is wrapped in a createMap factory and Map.groupBy (where available) is captured at module-load time and frozen into a tamper-proof namespace, so keyed-collection construction keeps working even if the global Map is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.

API Reference

ƒ Functions

§function

createMap<K, V>(iterable?: Iterable<unknown, any, any>): Map<K, V>

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

Parameters

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

Returns

Map<K, V>
A new Map instance.

Variables

§type

Map

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

mapGroupBy

(Safe copy) Groups elements by key using the captured Map.groupBy if available. Note: Available only in ES2024+ environments.