Class Map

An unordered iterable collection of key/value pairs that cannot contain two instances of the same key. It optionally enforces the type of the key and the type of the associated value.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(keytype: new(...args: any[]) => Object, valtype: new(...args: any[]) => Object): Map

This creates a Map that may check the types of the keys and/or values.

Parameters

  • keytype: new(...args: any[]) => Object

    if supplied, this must be a class function/constructor.

  • valtype: new(...args: any[]) => Object

    if supplied, this must be a class function/constructor.

Returns

Map

constructor(keytype: string, valtype: new(...args: any[]) => Object): Map

This creates a Map that may check the types of the keys and/or values.

Parameters

  • keytype: string

    if supplied, this must be one of: 'number' or 'string' for the key type.

  • valtype: new(...args: any[]) => Object

    if supplied, this must be a class function/constructor.

Returns

Map

constructor(keytype: new(...args: any[]) => Object, valtype: string): Map

This creates a Map that may check the types of the keys and/or values.

Parameters

  • keytype: new(...args: any[]) => Object

    if supplied, this must be a class function/constructor.

  • valtype: string

    if supplied, this must be one of: 'number', 'string', 'boolean', or 'function' for the value type.

Returns

Map

constructor(keytype?: string, valtype?: string): Map

This creates a Map that may check the types of the keys and/or values.

Parameters

  • keytype?: string optional

    if supplied, this must be one of: 'number' or 'string' for the key type.

  • valtype?: string optional

    if supplied, this must be one of: 'number', 'string', 'boolean', or 'function' for the value type.

Returns

Map

Properties

public count: number

Gets the number of associations in the Map.

public iterator: Iterator

Gets an object that you can use for iterating over the Map.

Methods

public add(key: any, val: any): boolean

Adds a key-value association to the Map, or replaces the value associated with the key if the key was already present in the map.

Parameters

  • key: any
  • val: any

Returns

boolean

public addAll(map: Map): Map

Adds all of the key-value pairs of another Map to this Map.

Parameters

Returns

Map

public clear(): any

Clears the Map, removing all key-value associations.

Returns

any

public contains(key: any): boolean

Returns whether the given key is in this Map.

Parameters

  • key: any

Returns

boolean

public copy(): Map

Makes a shallow copy of this Map.

Returns

Map

public getValue(key: any): any

Returns the value associated with a key.

Parameters

  • key: any

Returns

any

public remove(key: any): boolean

Removes a key (if found) from the Map.

Parameters

  • key: any

Returns

boolean

public toArray(): Array<any>

Produces a JavaScript Array of key/value pair objects from the contents of this Map.

Returns

Array<any>

public toKeySet(): Set

Produces a Set that provides a read-only view onto the keys of this Map.

Returns

Set