@elgato/streamdeck
Version:
The official Node.js SDK for creating Stream Deck plugins.
45 lines (44 loc) • 1.07 kB
JavaScript
import { Enumerable } from "@elgato/utils";
const __items = new Map();
/**
* Provides a read-only store of Stream Deck devices.
*/
export class ReadOnlyActionStore extends Enumerable {
/**
* Initializes a new instance of the {@link ReadOnlyActionStore}.
*/
constructor() {
super(__items);
}
/**
* Gets the action with the specified identifier.
* @param id Identifier of action to search for.
* @returns The action, when present; otherwise `undefined`.
*/
getActionById(id) {
return __items.get(id);
}
}
/**
* Provides a store of Stream Deck actions.
*/
class ActionStore extends ReadOnlyActionStore {
/**
* Deletes the action from the store.
* @param id The action's identifier.
*/
delete(id) {
__items.delete(id);
}
/**
* Adds the action to the store.
* @param action The action.
*/
set(action) {
__items.set(action.id, action);
}
}
/**
* Singleton instance of the action store.
*/
export const actionStore = new ActionStore();