# ProxyMap Class

Module
import { ProxyMap } from "@tsed/core"
Source/packages/core/src/class/ProxyMap.ts

# Overview

abstract class ProxyMap<T, I> implements Map<T, I> {
    protected registry: Map<T, I>;
    readonly [Symbol.toStringTag]: "Map";
    constructor(registry: Map<T, I>, mapSettings?: ProxyMapSettings);
    [Symbol.iterator](): IterableIterator<[T, I]>;
    clear(): void;
    delete(key: T): boolean;
    entries(): IterableIterator<[T, I]>;
    keys(): IterableIterator<T>;
    values(): IterableIterator<I>;
    forEach(callbackfn: (value: I, key: T, map: Map<T, I>) => void, thisArg?: any): void;
    get(key: T): I | undefined;
    set(key: T, value: I): this;
    has(key: T): boolean;
    get size(): number;
}

# Members

protected registry: Map<T, I>

readonly [Symbol.toStringTag]: "Map"

[Symbol.iterator](): IterableIterator<[T, I]>

clear(): void

The clear() method removes all elements from a Map object.


delete(key: T): boolean
Param Type Description
key T Required. The key of the element to remove from the Map object.

The delete() method removes the specified element from a Map object.


entries(): IterableIterator<[T, I]>

The entries() method returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.


keys(): IterableIterator<T>

The keys() method returns a new Iterator object that contains the keys for each element in the Map object in insertion order.


values(): IterableIterator<I>

The values() method returns a new Iterator object that contains the values for each element in the Map object in insertion order.


forEach(callbackfn: (value: I, key: T, map: Map<T, I>) => void, thisArg?: any): void
Param Type Description
callbackfn (value: I Function to execute for each element. thisArg

The forEach() method executes a provided function once per each key/value pair in the Map object, in insertion order.

The forEach method executes the provided callback once for each key of the map which actually exist. It is not invoked for keys which have been deleted. However, it is executed for values which are present but have the value undefined. callback is invoked with three arguments:

  • the element value
  • the element key
  • the Map object being traversed

If a thisArg parameter is provided to forEach, it will be passed to callback when invoked, for use as its this value. Otherwise, the value undefined will be passed for use as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.

Each value is visited once, except in the case when it was deleted and re-added before forEach has finished. callback is not invoked for values deleted before being visited. New values added before forEach has finished will be visited. forEach executes the callback function once for each element in the Map object; it does not return a value.


get(key: T): I | undefined
Param Type Description
key T Required. The key of the element to return from the Map object.

The get() method returns a specified element from a Map object.


set(key: T, value: I): this
Param Type Description
key T Required. The key of the element to add to the Map object. value

The set() method adds or updates an element with a specified key and value to a Map object.


has(key: T): boolean

The has() method returns a boolean indicating whether an element with the specified key exists or not.


get size(): number

Return the size of the map.