Constructor
new CborMap(iterableopt)
- Description:
- Creates an instance of CborMap.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterable |
Iterable.<any> |
<optional> |
An Array or other iterable
object whose elements are key-value pairs (arrays with two elements, e.g.
[[ 1, 'one' ],[ 2, 'two' ]] ). Each key-value pair is added
to the new CborMap; null values are treated as undefined. |
Extends
- Map
Methods
delete(key) → {boolean}
- Description:
- Removes the specified element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
any | The key identifying the element to delete. Can be any type, which will be serialized into CBOR and compared by value. |
Returns:
True if an element in the Map object existed and has
been removed, or false if the element does not exist.
- Type
- boolean
encodeCBOR(gen) → {boolean}
- Description:
- Push the simple value onto the CBOR stream.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
gen |
Returns:
True on success.
- Type
- boolean
(generator) entries() → {Array.<any>}
- Description:
- Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
- Source:
Returns:
Key value pairs.
- Type
- IterableIterator.<any>
Yields:
Key value pairs.
- Type
- Array.<any>
forEach(fun, thisArg)
- Description:
- Executes a provided function once per each key/value pair in the Map object, in insertion order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fun |
function | Function to execute for each element, which takes a value, a key, and the Map being traversed. |
thisArg |
any | Value to use as this when executing callback. |
Throws:
-
Invalid function.
- Type
- TypeError
get(key) → {any}
- Description:
- Retrieve a specified element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
any | The key identifying the element to retrieve. Can be any type, which will be serialized into CBOR and compared by value. |
Returns:
The element if it exists, or
undefined
.
- Type
- any
has(key) → {boolean}
- Description:
- Does an element with the specified key exist?
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
any | The key identifying the element to check. Can be any type, which will be serialized into CBOR and compared by value. |
Returns:
True if an element with the specified key exists in
the Map object; otherwise false.
- Type
- boolean
(generator) keys() → {MapIterator.<any>}
- Description:
- Returns a new Iterator object that contains the keys for each element in the Map object in insertion order. The keys are decoded into their original format.
- Source:
Returns:
- Type
- MapIterator.<any>
set(key, val) → {this}
- Description:
- Adds or updates an element with a specified key and value.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
any | The key identifying the element to store. Can be any type, which will be serialized into CBOR and compared by value. |
val |
any | The element to store. |
Returns:
This object.
- Type
- this