Class: EntryStore

barejs/polyfill.EntryStore(_iterableopt, _pairopt)

new EntryStore(_iterableopt, _pairopt)

EntryStore provides the actual Map (and Set) implementation. Its implementation is shaped by two features:

  1. Attempt to achieve the O(1) lookup time of the native Map and Set types (for String and Number values).
  2. Support iterators according to the spec.

Since we don't want to track iterators (as that would keep them alive indefinitely if iteration is aborted before end), the EntryStore never re-uses or changes an entry index. This allows iterators to keep pointing at a specific entry index, and look at the actual situation during the next call.

Parameters:
Name Type Attributes Description
_iterable * <optional>

Optional: an iterable whose values will be added to the EntryStore.

_pair boolean <optional>

Optional: if the EntryStore is used for a Map, this should be true (iterable's values should be interpreted as key-value pairs, not as single values).

Source:

Classes

Iterator

Methods

_nxt(_start) → {number}

Find the next valid index, starting at _start

Parameters:
Name Type Description
_start number

The index to start looking at. If _start is in entries, start is returned.

Source:
Returns:

The next valid index, or -1 if there is no next entry.

Type
number

clear()

Clear the EntryStore, removing all keys and associated values.

Source:

forEach(_iterated, Callback:, _thisArgopt)

Iterate the EntryStore (on behalf of _iterated)

Parameters:
Name Type Attributes Description
_iterated module:barejs/polyfill.EntryStore

The object to report as being iterated. Since the EntryStore is an internal object to be used by a Set or Map it has to report the correct object.

Callback: function

the iterator callback to call for every entry. Called with ( <key>, <value>, _iterated ).

_thisArg object <optional>

Optional: object to use as context for the callback function

Source:

indexOf(_key, _key) → {number}

Find the entry index for a key

Parameters:
Name Type Description
_key

The key to get the entry index for

_key

The key to get the entry index for

Source:
Returns:

The entry index, or -1

Type
number

remove(_key) → {boolean}

Remove _key from the EntryStore

Parameters:
Name Type Description
_key *

The key to remove the value for

Source:
Returns:

True if the value for _key got removed, false otherwise.

Type
boolean

set(_key, _value)

Set the entry for a key

Parameters:
Name Type Description
_key *

The key for the value.

_value *

The value to set.

Source: