Constructor
new CborMap(iterableopt)
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}
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:
- Type:
-
boolean
True if an element in the Map object existed and has
been removed, or false if the element does not exist.
encodeCBOR(gen) → {boolean}
Push the simple value onto the CBOR stream.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
gen |
object
|
The generator to push onto. |
Returns:
- Type:
-
boolean
True on success.
(generator) entries() → {IterableIterator.<any, any>}
Returns a new Iterator object that contains the [key, value] pairs for
each element in the Map object in insertion order.
- Source:
Returns:
- Type:
-
IterableIterator.<any, any>
Key value pairs.
forEach(fun, thisArg)
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}
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:
- Type:
-
any
The element if it exists, or
undefined.
has(key) → {boolean}
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:
- Type:
-
boolean
True if an element with the specified key exists in
the Map object; otherwise false.
(generator) keys()
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:
set(key, val) → {this}
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:
- Type:
-
this
This object.