The WeakMap object to store values with associated non-primitive (object) keys
Symbol refference of weakmap property
Allowed key types to store them in a weakmap instance
Returns an iterable of entries in the map.
Removes the associated value from the SmartMap object,
The key of the element to remove from the SmartMap object.
true
if an element in the SmartMap object existed and has been removed, or false
if the element does not exist. SmartMap.prototype.has(key)
will return false afterwards.
Returns an iterable of key, value pairs for every entry in the map.
Returns the value associated to the key, or undefined if there is none.
The key of the element to return from the SmartMap object.
The value associated to the key
Returns a boolean asserting whether a value has been associated to the key in the SmartMap object or not.
The key of the element to test for presence in the SmartMap object.
A boolean asserting whether a value has been associated to the key in the SmartMap object or not.
Returns a boolean whether if the key is storable in weakmap or not
Key to check if it can be stored in weakmap
A boolean whether if the key is storable in weakmap or not
Returns an iterable of keys in the map
Sets the value for the key in the SmartMap object.
The key of the element to add to the SmartMap object.
The value of the element to add to the SmartMap object.
Returns the SmartMap object.
Returns an iterable of values in the map
Generated using TypeDoc
### SmartMap
Like WeakMap but can also store values using primitive keys
Example usage:
import { SmartMap } from "@thalesrc/js-utils"; const aMap = new SmartMap(); aMap.set("foo", "foo"); aMap.set(1, "thales rocks"); console.log(aMap.size) // 2 aMap.set({}, "thales rocks again"); console.log(aMap.size) // 2 const anObject = {}; aMap.set(anObject, "thales rocks again and again"); console.log(aMap.size) // 3 console.log(aMap.get(anObject)) // "thales rocks again and again"
K Typeof Key
V Typeof Value