Skip to content

Commit

Permalink
biome changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter275 committed Aug 22, 2024
1 parent 9841d7d commit 933e107
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions example/nodeSerial/example.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/nodeSerialConnection.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/serialConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/nodeTransformHandler.ts
Original file line number Diff line number Diff line change
@@ -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<unknown>,
logger: Logger<unknown>,
onReleaseEvent: SimpleEventDispatcher<boolean>,
onDeviceDebugLog: SimpleEventDispatcher<Uint8Array>,
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(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/transformHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import * as Protobuf from "../protobufs.js";
import * as Types from "../types.js";

export const transformHandler = (
log: Logger<unknown>,
logger: Logger<unknown>,
onReleaseEvent: SimpleEventDispatcher<boolean>,
onDeviceDebugLog: SimpleEventDispatcher<Uint8Array>,
concurrentLogOutput: boolean,
) => {
let byteBuffer = new Uint8Array([]);
return new TransformStream<Uint8Array, Uint8Array>({
transform(chunk: Uint8Array, controller): void {
log = log.getSubLogger({ name: "streamTransformer" });
const log = logger.getSubLogger({ name: "streamTransformer" });
onReleaseEvent.subscribe(() => {
controller.terminate();
});
Expand Down

0 comments on commit 933e107

Please sign in to comment.