Dictionary
Class for handling string-indexed objects. Similar to Dictionaries or Advanced Lists in other languages
Kind: global class
-
Dictionary
-
instance
-
.getById(id) ⇒
any
- .add(id)
-
.remove(id) ⇒
any
- .forEach(callback)
-
.map(callback) ⇒
Array
- .getKeys()
-
.getById(id) ⇒
-
static
-
.fromObject(obj) ⇒
Dictionary.<T>
-
.fromObject(obj) ⇒
-
instance
dictionary.getById(id) ⇒ any
Gets the object listed under the specific ID. If no such item exists, returns null
Kind: instance method of Dictionary
Returns: any
- The object identified by the unique identifier
Param | Type | Description |
---|---|---|
id | string |
The unique identifier for the specified object |
dictionary.add(id)
Adds an object with a unique ID. If the ID is already taken, throws an error.
Kind: instance method of Dictionary
Throws:
- Invalid Identifier
Param | Type | Description |
---|---|---|
id | string |
The unique identifier for the specified object |
dictionary.remove(id) ⇒ any
Removes the object listed under the specific ID and returns the deleted object. If no such item exists, returns null
Kind: instance method of Dictionary
Returns: any
- The deleted object identified by the unique identifier
Param | Type | Description |
---|---|---|
id | string |
The unique identifier for the specified object |
dictionary.forEach(callback)
Iterates through the Ditcionary and performs an action on each item
Kind: instance method of Dictionary
Param | Type | Description |
---|---|---|
callback | function |
The Action to be performed on each iteration |
dictionary.map(callback) ⇒ Array
Iterates through the Ditcionary and performs an action on each item, returning an array of the iterated results.
Kind: instance method of Dictionary
Returns: Array
- An array of the iterated results.
Param | Type | Description |
---|---|---|
callback | function |
The Action to be performed on each iteration |
dictionary.getKeys()
Lists all the keys used in the Dictionary
Kind: instance method of Dictionary
Dictionary.fromObject(obj) ⇒ Dictionary.<T>
Created a Dictionary from a JavaScript object
Kind: static method of Dictionary
Param | Type |
---|---|
obj | Object |