SetMap class

Wraps a JavaScript Set instance as a map

API #

A map of Set objects.

new SetMap(set)

  • set: Set – Adds a new entry with a specified key and value to this Map, or updates an existing entry if the key already exists.

    If the readOnly property is true, calling this method throws a TypeError.

clear()

Returns: void

Removes all key/value entries from the map.

Unlike the standard Map.prototype.clear(), this method invokes an overridden keys() and delete() to ensure proper behavior in subclasses.

If the readOnly property is true, calling this method throws a TypeError.

delete(key)

  • key: any

Returns: any

Removes the entry for the given key, return true if an entry was removed and false if there was no entry for the key.

If the readOnly property is true, calling this method throws a TypeError.

entries()

Returns: MapIterator<[any, any]>

Returns a new Iterator object that contains a two-member array of [key, value] for each element in the map in insertion order.

Unlike the standard Map.prototype.clear(), this method invokes an overridden keys() and get() to ensure proper behavior in subclasses.

forEach(callback, [thisArg])

  • callback: (value: any, key: any, thisArg: any) => void
  • thisArg: any

Returns: void

Calls callback once for each key/value pair in the map, in insertion order.

Unlike the standard Map.prototype.forEach(), this method invokes an overridden entries() to ensure proper behavior in subclasses.

get(key)

  • key: any

Returns: any

Returns the value associated with the key, or undefined if there is none.

has(key)

  • key: any

Returns: any

Returns true if the given key appears in the set returned by keys().

It doesn’t matter whether the value returned by get() is defined or not.

If the requested key has a trailing slash but has no associated value, but the alternate form with a slash does appear, this returns true.

keys()

Returns: MapIterator

Returns a new Iterator object that contains the keys for each element in the map in insertion order.

parent

Type: SyncMap

The parent of this node in a tree.

readOnly

Type: boolean

True if the object is read-only. This will be true if the get() method has been overridden but set() and delete() have not.

set(key, value)

  • key: any
  • value: any

Returns: any

Adds a new entry with a specified key and value to this Map, or updates an existing entry if the key already exists.

If the readOnly property is true, calling this method throws a TypeError.

size

Type: any

Returns the number of keys in the map.

The size property invokes an overridden keys() to ensure proper behavior in subclasses. Because a subclass may not enforce a direct correspondence between keys() and get(), the size may not reflect the number of values that can be retrieved.

values()

Returns: MapIterator<[any]>

Returns a new Iterator object that contains the values for each element in the map in insertion order.