repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: revert schema usage for linted-staged: no supported
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
WorkerBroadcastChannel.ts
diff --git
a/src/charging-station/WorkerBroadcastChannel.ts
b/src/charging-station/WorkerBroadcastChannel.ts
index 96fe7c17df01c76471c384f03af3605175372013..f3c168bdc8f1057611d1b8768d6d1dde0364c627 100644
(file)
--- a/
src/charging-station/WorkerBroadcastChannel.ts
+++ b/
src/charging-station/WorkerBroadcastChannel.ts
@@
-1,19
+1,16
@@
-import { BroadcastChannel } from 'worker_threads';
+import { BroadcastChannel } from '
node:
worker_threads';
-import * as uuid from 'uuid';
-
-import type { JsonType } from '../types/JsonType';
import type {
BroadcastChannelRequest,
BroadcastChannelResponse,
import type {
BroadcastChannelRequest,
BroadcastChannelResponse,
+ JsonType,
MessageEvent,
MessageEvent,
-} from '../types/WorkerBroadcastChannel';
-import logger from '../utils/Logger';
-import Utils from '../utils/Utils';
+} from '../types';
+import { Utils, logger } from '../utils';
const moduleName = 'WorkerBroadcastChannel';
const moduleName = 'WorkerBroadcastChannel';
-export
default
abstract class WorkerBroadcastChannel extends BroadcastChannel {
+export abstract class WorkerBroadcastChannel extends BroadcastChannel {
protected constructor() {
super('worker');
}
protected constructor() {
super('worker');
}
@@
-27,32
+24,36
@@
export default abstract class WorkerBroadcastChannel extends BroadcastChannel {
}
protected isRequest(message: JsonType[]): boolean {
}
protected isRequest(message: JsonType[]): boolean {
- return Array.isArray(message) && message.length === 3;
+ return Array.isArray(message)
=== true
&& message.length === 3;
}
protected isResponse(message: JsonType[]): boolean {
}
protected isResponse(message: JsonType[]): boolean {
- return Array.isArray(message) && message.length === 2;
+ return Array.isArray(message)
=== true
&& message.length === 2;
}
protected validateMessageEvent(messageEvent: MessageEvent): MessageEvent | false {
if (Array.isArray(messageEvent.data) === false) {
logger.error(
}
protected validateMessageEvent(messageEvent: MessageEvent): MessageEvent | false {
if (Array.isArray(messageEvent.data) === false) {
logger.error(
- this.logPrefix(moduleName, 'validateMessageEvent') +
- ' Worker broadcast channel protocol message event data is not an array'
+ `${this.logPrefix(
+ moduleName,
+ 'validateMessageEvent'
+ )} Worker broadcast channel protocol message event data is not an array`
);
return false;
}
);
return false;
}
- if (
uuid.validate
(messageEvent.data[0]) === false) {
+ if (
Utils.validateUUID
(messageEvent.data[0]) === false) {
logger.error(
logger.error(
- this.logPrefix(moduleName, 'validateMessageEvent') +
- ' Worker broadcast channel protocol message event data UUID field is invalid'
+ `${this.logPrefix(
+ moduleName,
+ 'validateMessageEvent'
+ )} Worker broadcast channel protocol message event data UUID field is invalid`
);
return false;
}
return messageEvent;
}
);
return false;
}
return messageEvent;
}
- private logPrefix
(modName: string, methodName: string): string
{
+ private logPrefix
= (modName: string, methodName: string): string =>
{
return Utils.logPrefix(` Worker Broadcast Channel | ${modName}.${methodName}:`);
return Utils.logPrefix(` Worker Broadcast Channel | ${modName}.${methodName}:`);
- }
+ }
;
}
}