Global
This class is global

Augments

  • events.EventEmitter

Events

add

Emitted when a host is added to the map

remove

Emitted when a host is removed from the map

Constructor

new

HostMap

()

Represents an associative-array of hosts that can be iterated. It creates an internal copy when adding or removing, making it safe to iterate using the values() method within async operations.

Methods

clear

()

Removes all items from the map.

Returns:
Type Description
Array<Host>

The previous items

forEach

(callback)

Executes a provided function once per map element.

Parameters:
Name Type Description
callback

get

(String key)

Gets a host by key or undefined if not found.

Parameters:
Name Type Description
key String
Returns:
Type Description
Host

keys

()

Returns an array of host addresses.

Returns:
Type Description
Array<String>

remove

(String key)

Removes an item from the map.

Parameters:
Name Type Description
key String

The key of the host

removeMultiple

(Array<String> keys)

Removes multiple hosts from the map.

Parameters:
Name Type Description
keys Array<String>

set

(String key, Host value)

Adds a new item to the map.

Parameters:
Name Type Description
key String

The key of the host

value Host

The host to be added

values

()

Returns a shallow copy of the values of the map.

Returns:
Type Description
Array<Host>