1
0
Fork 0
mirror of https://github.com/moritzruth/node-enttec-open-dmx-usb.git synced 2025-04-21 07:41:22 +02:00

Unify wording in comments

This commit is contained in:
Moritz Ruth 2022-06-25 16:57:58 +02:00
parent a565e9e5b7
commit 36956cee74
2 changed files with 14 additions and 16 deletions

View file

@ -2,7 +2,7 @@
> A Node.js library for interacting with the > 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/) > [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). [these environments](https://serialport.io/docs/guide-platform-support#supported-platforms-and-architectures).
## Install ## Install
@ -41,4 +41,4 @@ import { EnttecOpenDMXUSBDevice as DMXDevice } from "enttec-open-dmx-usb";
## Events ## Events
`ready` - `startSending` can be called. `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.

View file

@ -18,7 +18,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
/** /**
* @param {string} path A path returned by {@link EnttecOpenDMXUSBDevice.listDevices} or * @param {string} path A path returned by {@link EnttecOpenDMXUSBDevice.listDevices} or
* {@link EnttecOpenDMXUSBDevice.getFirstAvailableDevice}. * {@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) { constructor(path: string, startSending = true) {
super() super()
@ -35,19 +35,17 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
this.emit("ready") this.emit("ready")
if (startSending) this.startSending(0) if (startSending) this.startSending(0)
}) })
// Forward SerialPort errors.
// If nothing is attaching to the SerialPort error event, the Node process will be terminated // Without this, errors would be uncaught.
// in case of an error (e.g. wrong device passed) which would not permit error handling in
// projects using this package.
this.port.on("error", (error: Error) => { this.port.on("error", (error: Error) => {
this.emit("error", error) this.emit("error", error)
}) })
} }
/** /**
* Starts sending. * Start sending.
* @param {number} [interval=0] The time between each attempt to send. * @param {number} [interval=0] The time between each attempt to send. Most of the time, `0` works.
* @throws Error If the device is not ready yet. * @throws Error When the device is not ready yet.
*/ */
startSending(interval = 0) { startSending(interval = 0) {
if (!this.port.isOpen) throw new Error("The device is not ready yet. Wait for the 'ready' event.") 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<Events> {
} }
/** /**
* Stops sending. * Stop sending.
*/ */
stopSending() { stopSending() {
this.shouldBeSending = false this.shouldBeSending = false
@ -78,7 +76,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
} }
/** /**
* Sets the channel values. * Set the channel values.
* If channels is an Object, the keys are the channel numbers. * If channels is an Object, the keys are the channel numbers.
* *
* @param {Buffer|Object|Array} channels * @param {Buffer|Object|Array} channels
@ -121,7 +119,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
} }
/** /**
* @returns {Promise} Resolves when the whole universe was send. * @returns {Promise} Resolves when the whole universe was sent.
* @private * @private
*/ */
private async sendUniverse(): Promise<void> { private async sendUniverse(): Promise<void> {
@ -139,7 +137,7 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
} }
/** /**
* Lists the paths of all available devices. * Get the paths of all available devices.
* @returns {Promise<string[]>} * @returns {Promise<string[]>}
*/ */
static async listDevices(): Promise<string[]> { static async listDevices(): Promise<string[]> {
@ -150,8 +148,8 @@ export class EnttecOpenDMXUSBDevice extends EventEmitter<Events> {
} }
/** /**
* Gets the path of the first available device found. * Get the path of the first available device.
* @throws Error when no device is found. * @throws Error When no device is found.
* @returns {Promise<string>} * @returns {Promise<string>}
*/ */
static async getFirstAvailableDevice(): Promise<string> { static async getFirstAvailableDevice(): Promise<string> {