diff --git a/lib/cli/ioServerService.ts b/lib/cli/ioServerService.ts index f600cd4..168d8b5 100644 --- a/lib/cli/ioServerService.ts +++ b/lib/cli/ioServerService.ts @@ -1,4 +1,4 @@ -const { ArgumentParser } = require("argparse"); +const ArgumentParser = require("argparse").ArgumentParser; const parser = new ArgumentParser({ // version: "1.0.0", @@ -153,4 +153,5 @@ switch (parser.parse_args().mode) { default: logger.error("Invalid mode have been provided"); + break; } diff --git a/lib/cli/nope.ts b/lib/cli/nope.ts index 8d7c0d2..6bde1c1 100644 --- a/lib/cli/nope.ts +++ b/lib/cli/nope.ts @@ -40,11 +40,8 @@ export async function main() { type: "str", }; - switch (args.mode) { - default: - case "help": - case "none": - console.log(`NoPE - Command Line Interface. + const showLog = () => { + console.log(`NoPE - Command Line Interface. Please select the option you want. Therefore add one of the following options: \x1b[4mhelp\x1b[0m Show this help. @@ -73,7 +70,18 @@ Have fun using NoPE :) |___________| `); - return; + }; + + switch (args.mode) { + default: + showLog(); + break; + case "help": + showLog(); + break; + case "none": + showLog(); + break; case "run": await run([additionalArg]); break; diff --git a/lib/dispatcher/ConnectivityManager/ConnectivityManager.ts b/lib/dispatcher/ConnectivityManager/ConnectivityManager.ts index 307477f..d6b676f 100644 --- a/lib/dispatcher/ConnectivityManager/ConnectivityManager.ts +++ b/lib/dispatcher/ConnectivityManager/ConnectivityManager.ts @@ -385,7 +385,7 @@ export class NopeConnectivityManager implements INopeConnectivityManager { }); // Wait until the Element is connected. - await this._communicator.connected.waitFor((value) => value); + await this._communicator.connected.waitFor(); await this._communicator.on("StatusChanged", (info) => { _this._externalDispatchers.set(info.id, info); diff --git a/lib/dispatcher/InstanceManager/InstanceManager.ts b/lib/dispatcher/InstanceManager/InstanceManager.ts index b766cad..d683b90 100644 --- a/lib/dispatcher/InstanceManager/InstanceManager.ts +++ b/lib/dispatcher/InstanceManager/InstanceManager.ts @@ -187,7 +187,7 @@ export class NopeInstanceManager implements INopeInstanceManager { this._rpcManager = new NopeRpcManager( options, _generateObservable, - async () => "test", + this._defaultSelector, this._id ); } @@ -226,9 +226,11 @@ export class NopeInstanceManager implements INopeInstanceManager { // Filter the Generators based on the existing services const generators = services.services .filter((svc) => - svc?.id.startsWith( + { + return svc?.id.startsWith( `nope${SPLITCHAR}core${SPLITCHAR}constructor${SPLITCHAR}` - ) + ); + } ) .map((item) => { return item.id; @@ -271,9 +273,10 @@ export class NopeInstanceManager implements INopeInstanceManager { this._communicator.emit("InstancesChanged", { dispatcher: this._id, // We will send the descriptions. - instances: Array.from(this._internalInstances).map((identifier) => - // Generate the Module Description for every identifier: - _this._instances.get(identifier).instance.toDescription() + instances: Array.from(this._internalInstances).map((identifier) => { + // Generate the Module Description for every identifier: + return _this._instances.get(identifier).instance.toDescription(); + } ), }); @@ -402,9 +405,8 @@ export class NopeInstanceManager implements INopeInstanceManager { .instance.toDescription(); } else { // Now extract teh - for (const { - instances, - } of this._mappingOfRemoteDispatchersAndInstances.values()) { + for (const item of this._mappingOfRemoteDispatchersAndInstances.values()) { + const instances = item.instances; for (const instance of instances) { if (instance.identifier == identifier) { ret.description = instance; @@ -668,9 +670,9 @@ export class NopeInstanceManager implements INopeInstanceManager { // If that isnt the case, we will check all dispatchers and search the instance. for (const [ dispatcher, - { instances }, + msg, ] of this._mappingOfRemoteDispatchersAndInstances.entries()) { - for (const instance of instances) { + for (const instance of msg.instances) { if (instance.identifier == identifier) { return this._statusManager.getStatus(dispatcher); } diff --git a/lib/dispatcher/InstanceManager/assignmentCheckers.ts b/lib/dispatcher/InstanceManager/assignmentCheckers.ts index fbf99c7..eba6243 100644 --- a/lib/dispatcher/InstanceManager/assignmentCheckers.ts +++ b/lib/dispatcher/InstanceManager/assignmentCheckers.ts @@ -28,8 +28,15 @@ export function generateAssignmentChecker( ): TValidAsssignmentChecker { switch (selector) { default: + throw Error("Please provide an valid selector"); case "first": + return async () => { + return true; + }; case "cpu-usage": + return async () => { + return true; + }; case "free-ram": return async () => { return true; diff --git a/lib/dispatcher/RpcManager/NopeRpcManager.ts b/lib/dispatcher/RpcManager/NopeRpcManager.ts index ae9209d..44d98c6 100644 --- a/lib/dispatcher/RpcManager/NopeRpcManager.ts +++ b/lib/dispatcher/RpcManager/NopeRpcManager.ts @@ -333,7 +333,9 @@ export class NopeRpcManager const args = []; // First extract the basic arguments - data.params.map((item) => (args[item.idx] = item.data)); + data.params.map((item) => { + args[item.idx] = item.data; + }); // Perform the Task it self. const _resultPromise = _function(...args); @@ -343,7 +345,9 @@ export class NopeRpcManager ) { // Push the Callback to the Result. cbs.push((reason) => - (_resultPromise as INopePromise).cancel(reason) + { + return (_resultPromise as INopePromise).cancel(reason); + } ); } @@ -501,12 +505,12 @@ export class NopeRpcManager } }); - await this._communicator.on("RpcRequest", (data) => - _this._handleExternalRequest(data) - ); - await this._communicator.on("RpcResponse", (data) => - _this._handleExternalResponse(data) - ); + await this._communicator.on("RpcRequest", (data) => { + _this._handleExternalRequest(data); + }); + await this._communicator.on("RpcResponse", (data) => { + _this._handleExternalResponse(data); + }); // We will listen on Cancelations. await this._communicator.on("TaskCancelation", (event) => { diff --git a/lib/dispatcher/RpcManager/selectors.ts b/lib/dispatcher/RpcManager/selectors.ts index 676aa33..ddd9d61 100644 --- a/lib/dispatcher/RpcManager/selectors.ts +++ b/lib/dispatcher/RpcManager/selectors.ts @@ -28,6 +28,7 @@ export function generateSelector( ): ValidSelectorFunction { switch (selector) { default: + throw Error("Please use a valid selector"); case "master": return async (opts) => { const masterId = core.connectivityManager.master.id; @@ -79,8 +80,10 @@ export function generateSelector( const items = Array.from(data.get(opts.serviceName)); const hosts = items.map( (id) => - core.connectivityManager.dispatchers.originalData.get(id)?.host - .name + { + return core.connectivityManager.dispatchers.originalData.get(id)?.host + .name; + } ); const idx = hosts.indexOf(host); if (idx >= 0) { diff --git a/lib/dispatcher/nopeDispatcher.ts b/lib/dispatcher/nopeDispatcher.ts index bcc432a..b6f423c 100644 --- a/lib/dispatcher/nopeDispatcher.ts +++ b/lib/dispatcher/nopeDispatcher.ts @@ -89,7 +89,9 @@ export class NopeDispatcher extends NopeCore implements INopeDispatcher { } return items.filter( - (item) => comparePatternAndPath(pattern, item).affected + (item) =>{ + return comparePatternAndPath(pattern, item).affected; + } ); } diff --git a/lib/eventEmitter/nopeEventEmitter.ts b/lib/eventEmitter/nopeEventEmitter.ts index 6550bff..5c0c15e 100644 --- a/lib/eventEmitter/nopeEventEmitter.ts +++ b/lib/eventEmitter/nopeEventEmitter.ts @@ -215,6 +215,8 @@ export class NopeEventEmitter< callImmediate(observer.next, value, rest); break; default: + observer.next(value, rest as any as Partial); + break; case "sync": observer.next(value, rest as any as Partial); break; @@ -249,6 +251,8 @@ export class NopeEventEmitter< callImmediate(observer, value, rest); break; default: + observer(value, rest as any as Partial); + break; case "sync": observer(value, rest as any as Partial); break; @@ -345,8 +349,10 @@ export class NopeEventEmitter< * @param options Additional Options for the Wait Function. */ public waitFor( - testCallback: IWaitForCallback = (value) => - (value as any as boolean) == true, + testCallback: IWaitForCallback = (value) => { + return (value as any as boolean) == true; + } + , options: INopeWaitForObservableChangeOptions = { testCurrent: true } ): Promise { const _this = this; diff --git a/lib/helpers/arrayMethods.ts b/lib/helpers/arrayMethods.ts index b414f7f..16100a1 100644 --- a/lib/helpers/arrayMethods.ts +++ b/lib/helpers/arrayMethods.ts @@ -175,7 +175,9 @@ export function countElements(array: Array): Map { export function flattenDeep(arrayToFlatten) { return arrayToFlatten.reduce( (acc, val) => - Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val), + { + return Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val); + }, [] ) as T[]; } @@ -253,9 +255,9 @@ export function minOfArray( }; } - const arrOfValues = arr.map((item) => - rgetattr(item, path as string, defaultValue) - ) as number[]; + const arrOfValues = arr.map((item) =>{ + return rgetattr(item, path as string, defaultValue); + }); const min = Math.min(...arrOfValues); return { min, @@ -278,9 +280,9 @@ export function maxOfArray( }; } - const arrOfValues = arr.map((item) => - rgetattr(item, path, defaultValue) - ) as number[]; + const arrOfValues = arr.map((item) =>{ + return rgetattr(item, path, defaultValue); + }); const max = Math.max(...arrOfValues); return { max: max, diff --git a/lib/helpers/objectMethods.ts b/lib/helpers/objectMethods.ts index e6af445..07bc8e3 100644 --- a/lib/helpers/objectMethods.ts +++ b/lib/helpers/objectMethods.ts @@ -175,7 +175,9 @@ export function convertData( } } - return Object.getOwnPropertyNames(helper).map((key) => helper[key]) as T[]; + return Object.getOwnPropertyNames(helper).map((key) => { + return helper[key] as T; + }); } /** @@ -611,11 +613,10 @@ export function deepClone(obj: T): T { return null; } const clone: any = Object.assign({}, obj); - Object.keys(clone).forEach( - (key) => - (clone[key] = - typeof obj[key] === "object" ? deepClone(obj[key]) : obj[key]) - ); + Object.keys(clone).forEach((key) => { + clone[key] = + typeof obj[key] === "object" ? deepClone(obj[key]) : obj[key]; + }); return ( Array.isArray(obj) && obj.length ? (clone.length = obj.length) && Array.from(clone) diff --git a/lib/helpers/stringMethods.ts b/lib/helpers/stringMethods.ts index c0d71f6..5277335 100644 --- a/lib/helpers/stringMethods.ts +++ b/lib/helpers/stringMethods.ts @@ -55,7 +55,9 @@ export function padString( } let s = num + ""; - while (s.length < _size) s = "0" + s; + while (s.length < _size) { + s = "0" + s; + } return s; } diff --git a/lib/module/BaseModule.ts b/lib/module/BaseModule.ts index 71d3cef..0fc3ae5 100644 --- a/lib/module/BaseModule.ts +++ b/lib/module/BaseModule.ts @@ -465,6 +465,7 @@ export class NopeBaseModule implements INopeModule { _this[entry.accessor], entry.options as IEventOptions ); + break; } } } @@ -510,8 +511,11 @@ export class NopeBaseModule implements INopeModule { for (const [ name, - { observable, options }, + item, ] of this._registeredProperties.entries()) { + + const { observable, options } = item; + if (observable == propOrFunc) { const _subTopic = typeof options.topic === "string" @@ -545,8 +549,9 @@ export class NopeBaseModule implements INopeModule { } for (const [ name, - { func, options }, + item, ] of this._registeredFunctions.entries()) { + const { func, options } = item; if (func == propOrFunc) { return options.id; } diff --git a/lib/pubSub/nopePubSubSystem.ts b/lib/pubSub/nopePubSubSystem.ts index 500f499..e869bdc 100644 --- a/lib/pubSub/nopePubSubSystem.ts +++ b/lib/pubSub/nopePubSubSystem.ts @@ -397,7 +397,10 @@ export class PubSubSystemBase< // Clears all defined Matches this._matched.clear(); // Iterate through all Publishers and - for (const [emitter, { pubTopic, subTopic }] of this._emitters.entries()) { + for (const [emitter, item] of this._emitters.entries()) { + + const { pubTopic, subTopic } = item; + // Now, lets Update the Matching for the specific Topics. if (pubTopic) this._updateMatchingForTopic(pubTopic); if (subTopic) @@ -515,7 +518,10 @@ export class PubSubSystemBase< _subTopic: string | false ): void { // Iterate through all Publishers and - for (const { pubTopic } of this._emitters.values()) { + for (const item of this._emitters.values()) { + // Extract the Pub-Topic + const pubTopic = item.pubTopic; + // Now, lets Update the Matching for the specific Topics. if (mode === "remove" && pubTopic && _subTopic) { this.__deleteMatchingEntry(pubTopic, _subTopic, _emitter); @@ -598,10 +604,10 @@ export class PubSubSystemBase< } // Find all Matches - for (const [emitter, { subTopic }] of this._emitters.entries()) { - if (subTopic) { + for (const [emitter, item] of this._emitters.entries()) { + if (item.subTopic) { // Now lets determine the Path - this.__addMatchingEntryIfRequired(topicOfChange, subTopic, emitter); + this.__addMatchingEntryIfRequired(topicOfChange, item.subTopic, emitter); } } }