UNPKG

@ginden/blinkstick-v2

Version:
26 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createBlinkstickAsync = createBlinkstickAsync; const node_hid_1 = require("node-hid"); const blinkstick_finalization_registry_1 = require("../../../core/blinkstick-finalization-registry"); const blinkstick_async_1 = require("../../../core/versions/blinkstick.async"); /** * @summary This function creates a BlinkstickAsync instance from a USB device. * @remarks It also registers the BlinkStick object in a FinalizationRegistry to increase the chance that the device will be closed * when the object is garbage collected. * * This function is unlikely to be needed by end users, but you are an adult. * * @param device * @category Discovery */ async function createBlinkstickAsync(device) { const hidDevice = device.path ? await node_hid_1.HIDAsync.open(device.path) : await node_hid_1.HIDAsync.open(device.vendorId, device.productId); const blinkstick = new blinkstick_async_1.BlinkstickAsync(hidDevice, await hidDevice.getDeviceInfo()); const hidTransport = blinkstick.getTransport(); blinkstick_finalization_registry_1.blinkstickFinalizationRegistry.register(blinkstick, hidTransport, blinkstick); return blinkstick; } //# sourceMappingURL=create-blinkstick-async.js.map