Class: Set

barejs/polyfill.Set()

Mimics the implementation of a native Set. 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 Set()

Source:

Classes

SetIterator

Members

(readonly) size :number

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

Type:
  • number
Source:

Methods

add(_value) → {module:barejs/polyfill.Set}

Adds a value to a Set object.

Parameters:
Name Type Description
_value

The value to add.

Source:
Returns:

The Set (for chaining)

Type
module:barejs/polyfill.Set

clear()

Clear the Set.

Source:

delete(_value) → {boolean}

Remove a value from the Set

Parameters:
Name Type Description
_value object

The value to remove.

Source:
Returns:

True if the value was deleted, false otherwise.

Type
boolean

entries() → {module:barejs/polyfill.Set~SetIterator}

Get an entry iterator

Source:
Returns:

A entry iterator

Type
module:barejs/polyfill.Set~SetIterator

forEach(_callback, _thisArgopt)

Iterate the Set

Parameters:
Name Type Attributes Description
_callback function

The callback function.

_thisArg <optional>

Optional: context to call the callback in.

Source:

has(_value) → {boolean}

Check if the Set has a specified value.

Parameters:
Name Type Description
_value object

The value to check for.

Source:
Returns:

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

Type
boolean

keys() → {module:barejs/polyfill.Set~SetIterator}

Get a key iterator

Source:
Returns:

A key iterator

Type
module:barejs/polyfill.Set~SetIterator

values() → {module:barejs/polyfill.Set~SetIterator}

Get a value iterator

Source:
Returns:

A value iterator

Type
module:barejs/polyfill.Set~SetIterator