From 933e107ccb3059fc41423b10a4f6a686de86d9aa Mon Sep 17 00:00:00 2001 From: Hunter Thornsberry Date: Thu, 22 Aug 2024 15:28:48 -0400 Subject: [PATCH] biome changes --- example/nodeSerial/example.js | 7 +++---- src/adapters/nodeSerialConnection.ts | 6 +++--- src/adapters/serialConnection.ts | 4 ++-- src/utils/nodeTransformHandler.ts | 6 +++--- src/utils/transformHandler.ts | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/example/nodeSerial/example.js b/example/nodeSerial/example.js index ca5a612..e7e9563 100644 --- a/example/nodeSerial/example.js +++ b/example/nodeSerial/example.js @@ -1,5 +1,5 @@ -import { NodeSerialConnection } from "./dist/index.js"; import { SerialPort } from "serialport"; +import { NodeSerialConnection } from "./dist/index.js"; const Connect = async () => { const connection = new NodeSerialConnection(); @@ -41,8 +41,8 @@ const Connect = async () => { console.log("NodeInfo: ", packet); }); const onMessage = (sender, message) => { - console.log("Message from: " + sender); - console.log("Message was: " + message); + console.log(`Message from: ${sender}`); + console.log(`Message was: ${message}`); }; connection.events.onRemoteHardwarePacket.subscribe((packet) => { @@ -59,7 +59,6 @@ const Connect = async () => { // Request configuration data from device (I think this will help trigger other serial events being processed) await connection.configure(); - }; Connect().catch((err) => { diff --git a/src/adapters/nodeSerialConnection.ts b/src/adapters/nodeSerialConnection.ts index ad551b1..31b7867 100644 --- a/src/adapters/nodeSerialConnection.ts +++ b/src/adapters/nodeSerialConnection.ts @@ -1,7 +1,7 @@ +import * as SerialPort from "serialport"; import { SimpleEventDispatcher } from "ste-simple-events"; import { MeshDevice } from "../meshDevice.js"; import * as Types from "../types.js"; -import * as SerialPort from "serialport"; import { nodeTransformHandler } from "../utils/index.js"; export class NodeSerialConnection extends MeshDevice { @@ -11,7 +11,7 @@ export class NodeSerialConnection extends MeshDevice { protected portId: string; /** Serial port used to communicate with device. */ - public port: any | undefined; + public port: SerialPort.SerialPort | undefined; /**Path to the serial port being opened. */ private portPath: string | undefined; @@ -109,7 +109,7 @@ export class NodeSerialConnection extends MeshDevice { this.complete(); }); - this.port.on("error", (err: any) => { + this.port.on("error", (err: Error) => { console.log(err); }); } diff --git a/src/adapters/serialConnection.ts b/src/adapters/serialConnection.ts index ecc3b2d..bc3b91f 100644 --- a/src/adapters/serialConnection.ts +++ b/src/adapters/serialConnection.ts @@ -142,8 +142,8 @@ export class SerialConnection extends MeshDevice { this.pipePromise = this.port.readable.pipeTo( this.transformer.writable, ); - const reader = (this.readerHack = - this.transformer.readable.getReader()); + this.readerHack = this.transformer.readable.getReader(); + const reader = this.readerHack; this.readFromRadio(reader); this.updateDeviceStatus(Types.DeviceStatusEnum.DeviceConnected); diff --git a/src/utils/nodeTransformHandler.ts b/src/utils/nodeTransformHandler.ts index 4e7dfa8..9faf0e2 100644 --- a/src/utils/nodeTransformHandler.ts +++ b/src/utils/nodeTransformHandler.ts @@ -1,17 +1,17 @@ +import { Transform } from "node:stream"; import type { SimpleEventDispatcher } from "ste-simple-events"; import type { Logger } from "tslog"; import * as Protobuf from "../protobufs.js"; import * as Types from "../types.js"; -import { Transform } from "stream"; export const nodeTransformHandler = ( - log: Logger, + logger: Logger, onReleaseEvent: SimpleEventDispatcher, onDeviceDebugLog: SimpleEventDispatcher, concurrentLogOutput: boolean, ) => { let byteBuffer = new Uint8Array([]); - log = log.getSubLogger({ name: "streamTransfer" }); + const log = logger.getSubLogger({ name: "streamTransfer" }); return new Transform({ transform(chunk: Buffer | Uint8Array, _encoding, controller) { onReleaseEvent.subscribe(() => { diff --git a/src/utils/transformHandler.ts b/src/utils/transformHandler.ts index db454c9..dae98cd 100644 --- a/src/utils/transformHandler.ts +++ b/src/utils/transformHandler.ts @@ -4,7 +4,7 @@ import * as Protobuf from "../protobufs.js"; import * as Types from "../types.js"; export const transformHandler = ( - log: Logger, + logger: Logger, onReleaseEvent: SimpleEventDispatcher, onDeviceDebugLog: SimpleEventDispatcher, concurrentLogOutput: boolean, @@ -12,7 +12,7 @@ export const transformHandler = ( let byteBuffer = new Uint8Array([]); return new TransformStream({ transform(chunk: Uint8Array, controller): void { - log = log.getSubLogger({ name: "streamTransformer" }); + const log = logger.getSubLogger({ name: "streamTransformer" }); onReleaseEvent.subscribe(() => { controller.terminate(); });