@aeontek/dictionary
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

Dictionary

Class for handling string-indexed objects. Similar to Dictionaries or Advanced Lists in other languages

Kind: global class

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

Readme

Keywords

none

Package Sidebar

Install

npm i @aeontek/dictionary

Weekly Downloads

0

Version

1.0.12

License

MIT

Unpacked Size

11.7 kB

Total Files

6

Last publish

Collaborators

  • attanai