CborMap

CborMap

new CborMap(args)

Creates an instance of CborMap.
Source:
Parameters:
Name Type Description
args Iterable.<Array.<any, any>> 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.

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

encodeCBOR(gen) → {boolean}

Push the simple value onto the CBOR stream
Source:
Parameters:
Name Type Description
gen cbor.Encoder The generator to push onto
Returns:
Type:
boolean
true on success

(generator) entries() → {Iterator.<Array.<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:
Iterator.<Array.<any, any>>

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

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

(generator) keys() → {Iterator.<any>}

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:
Iterator.<any>

set(key, val)

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

CborMap

new CborMap()

Wrapper around a JavaScript Map object that allows the keys to be any complex type. The base Map object allows this, but will only compare the keys by identity, not by value. CborMap translates keys to CBOR first (and base64's them to ensure by-value comparison). This is not a subclass of Object, because it would be tough to get the semantics to be an exact match.
Source:

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

encodeCBOR(gen) → {boolean}

Push the simple value onto the CBOR stream
Source:
Parameters:
Name Type Description
gen cbor.Encoder The generator to push onto
Returns:
Type:
boolean
true on success

(generator) entries() → {Iterator.<Array.<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:
Iterator.<Array.<any, any>>

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

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

(generator) keys() → {Iterator.<any>}

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:
Iterator.<any>

set(key, val)

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