@elgato/streamdeck
Version:
The official Node.js SDK for creating Stream Deck plugins.
38 lines (37 loc) • 1.04 kB
JavaScript
import { Enumerable } from "@elgato/utils";
const __items = new Map();
/**
* Provides a read-only store of Stream Deck devices.
*/
export class ReadOnlyDeviceStore extends Enumerable {
/**
* Initializes a new instance of the {@link ReadOnlyDeviceStore}.
*/
constructor() {
super(__items);
}
/**
* Gets the Stream Deck {@link Device} associated with the specified {@link deviceId}.
* @param deviceId Identifier of the Stream Deck device.
* @returns The Stream Deck device information; otherwise `undefined` if a device with the {@link deviceId} does not exist.
*/
getDeviceById(deviceId) {
return __items.get(deviceId);
}
}
/**
* Provides a store of Stream Deck devices.
*/
class DeviceStore extends ReadOnlyDeviceStore {
/**
* Adds the device to the store.
* @param device The device.
*/
set(device) {
__items.set(device.id, device);
}
}
/**
* Singleton instance of the device store.
*/
export const deviceStore = new DeviceStore();