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
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 |
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 |
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 |
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 |
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 |
Lists all the keys used in the Dictionary
Kind: instance method of Dictionary
Created a Dictionary from a JavaScript object
Kind: static method of Dictionary
Param | Type |
---|---|
obj | Object |