Class: Map

barejs/polyfill.Map()

Mimics the implementation of a native Map. Has an O(n) lookup time for non String or Number keys, so cannot compete with a native Map (Which is supposed to have an O(1) lookup time).

Constructor

new Map()

Source:

Classes

MapIterator

Members

(readonly) size :number

The size of the Map, which represents the number of entries currently in the Map.

Type:
  • number
Source:

Methods

delete(_key) → {boolean}

Remove the value for the specified key

Parameters:
Name Type Description
_key object

The object to use as key.

Source:
Returns:

True if the entry was deleted, false otherwise

Type
boolean

entries() → {module:barejs/polyfill.Map~MapIterator}

Get an entry iterator

Source:
Returns:

A entry iterator

Type
module:barejs/polyfill.Map~MapIterator

forEach(_callback, _thisArgopt)

Iterate the Map

Parameters:
Name Type Attributes Description
_callback function

The callback function.

_thisArg <optional>

Optional: context to call the callback in.

Source:

get(_key)

Get the value for the specified key

Parameters:
Name Type Description
_key object

The object to use as key.

Source:
Returns:

The value, or undefined if the key is not known.

has(_key) → {boolean}

Check if the Map has an entry for the specified key

Parameters:
Name Type Description
_key object

The object to use as key.

Source:
Returns:

True if there is an entry for the key, false otherwise

Type
boolean

keys() → {module:barejs/polyfill.Map~MapIterator}

Get a key iterator

Source:
Returns:

A key iterator

Type
module:barejs/polyfill.Map~MapIterator

set(_key, _value) → {module:barejs/polyfill.Map}

Set a value for the specified key in the Map.

Parameters:
Name Type Description
_key

The object to use as key.

_value

The value to add.

Source:
Returns:

The Map (for chaining)

Type
module:barejs/polyfill.Map

values() → {module:barejs/polyfill.Map~MapIterator}

Get a value iterator

Source:
Returns:

A value iterator

Type
module:barejs/polyfill.Map~MapIterator