UNPKG

node-buzzers

Version:

Forked version of 'buzz-buzzers', updated and upgraded to support multiple USB dongles

27 lines 1.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const node_hid_1 = __importDefault(require("node-hid")); const buzzer_1 = __importDefault(require("./buzzer")); const connectDevice_1 = __importDefault(require("./connectDevice")); const device_1 = __importDefault(require("./device")); const hardware_1 = __importDefault(require("./hardware")); const mapDeviceDataToPressedButtons_1 = __importDefault(require("./parser/mapDeviceDataToPressedButtons")); const mapperFn = (0, mapDeviceDataToPressedButtons_1.default)(); module.exports = (singleMode = true) => { if (singleMode) { return (0, buzzer_1.default)((0, device_1.default)(connectDevice_1.default, mapperFn)); } const buzzers = []; const devices = node_hid_1.default.devices(); const buzzDongles = devices.filter((d) => d.vendorId === hardware_1.default.VENDOR_ID && d.productId === hardware_1.default.PRODUCT_ID); buzzDongles.forEach((bd) => { if (typeof (bd === null || bd === void 0 ? void 0 : bd.path) === "string") { buzzers.push((0, buzzer_1.default)((0, device_1.default)(() => new node_hid_1.default.HID(`${bd.path}`), mapperFn))); } }); return buzzers; }; //# sourceMappingURL=index.js.map