Collections: Class
The Collections
class is a generic class for managing collections of items.
Usage
const { Collections } = require('chat-bridge')
Constructor
To create a new Collections
instance, use the following syntax:
const collections = new Collections()
Methods
add
Adds an item to the collection.
collections.add({ name: 'item1', value: 1 })
get
Retrieves an item from the collection by name.
collections.get('item1') // { name: 'item1', value: 1 }
Example
// Instantiate a new Collections
const collections = new Collections()
// Add an item to the collection
collections.add({ name: 'item1', value: 1 })
collections.add({ name: 'item2', value: 2 })
// Retrieve an item from the collection
collections.get('item1') // { name: 'item1', value: 1 }
collections.get('item2') // { name: 'item2', value: 2 }
collections.get('item3') // undefined