diff --git a/README.md b/README.md index 4ce3864..bfc2609 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > A Node.js library for interacting with the > [Enttec Open DMX USB Interface](https://www.enttec.co.uk/en/product/controls/dmx-usb-interfaces/open-dmx-usb/) -Only tested on Windows, but as it uses `serialport` under the hood, it should also work in +As it uses `serialport` under the hood, it should also work in [these environments](https://serialport.io/docs/guide-platform-support#supported-platforms-and-architectures). ## Install @@ -41,4 +41,4 @@ import { EnttecOpenDMXUSBDevice as DMXDevice } from "enttec-open-dmx-usb"; ## Events `ready` - `startSending` can be called. -`error` - An error occurred. The error can also originate from SerialPort. +`error` - An error occurred. `error` events from `serialport` are passed through. diff --git a/src/index.ts b/src/index.ts index c967f92..10858d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { /** * @param {string} path A path returned by {@link EnttecOpenDMXUSBDevice.listDevices} or * {@link EnttecOpenDMXUSBDevice.getFirstAvailableDevice}. - * @param {boolean} [startSending=true] If the device should start sending as soon as it is ready. + * @param {boolean} [startSending=true] Whether the device should start sending as soon as it is ready. */ constructor(path: string, startSending = true) { super() @@ -35,19 +35,17 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { this.emit("ready") if (startSending) this.startSending(0) }) - // Forward SerialPort errors. - // If nothing is attaching to the SerialPort error event, the Node process will be terminated - // in case of an error (e.g. wrong device passed) which would not permit error handling in - // projects using this package. + + // Without this, errors would be uncaught. this.port.on("error", (error: Error) => { this.emit("error", error) }) } /** - * Starts sending. - * @param {number} [interval=0] The time between each attempt to send. - * @throws Error If the device is not ready yet. + * Start sending. + * @param {number} [interval=0] The time between each attempt to send. Most of the time, `0` works. + * @throws Error When the device is not ready yet. */ startSending(interval = 0) { if (!this.port.isOpen) throw new Error("The device is not ready yet. Wait for the 'ready' event.") @@ -69,7 +67,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { } /** - * Stops sending. + * Stop sending. */ stopSending() { this.shouldBeSending = false @@ -78,7 +76,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { } /** - * Sets the channel values. + * Set the channel values. * If channels is an Object, the keys are the channel numbers. * * @param {Buffer|Object|Array} channels @@ -121,7 +119,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { } /** - * @returns {Promise} Resolves when the whole universe was send. + * @returns {Promise} Resolves when the whole universe was sent. * @private */ private async sendUniverse(): Promise { @@ -139,7 +137,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { } /** - * Lists the paths of all available devices. + * Get the paths of all available devices. * @returns {Promise} */ static async listDevices(): Promise { @@ -150,8 +148,8 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter { } /** - * Gets the path of the first available device found. - * @throws Error when no device is found. + * Get the path of the first available device. + * @throws Error When no device is found. * @returns {Promise} */ static async getFirstAvailableDevice(): Promise {