diff --git a/.coverage-badges/badge-branches.svg b/.coverage-badges/badge-branches.svg
index c43f36b..e9dbd7c 100644
--- a/.coverage-badges/badge-branches.svg
+++ b/.coverage-badges/badge-branches.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.coverage-badges/badge-lines.svg b/.coverage-badges/badge-lines.svg
index 61420d0..cbb01ce 100644
--- a/.coverage-badges/badge-lines.svg
+++ b/.coverage-badges/badge-lines.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.coverage-badges/badge-statements.svg b/.coverage-badges/badge-statements.svg
index 76595ff..3f8ebb1 100644
--- a/.coverage-badges/badge-statements.svg
+++ b/.coverage-badges/badge-statements.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 6691dd7..1517c83 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "zilaws-client",
- "version": "1.1.3",
+ "version": "2.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "zilaws-client",
- "version": "1.1.3",
+ "version": "2.0.0",
"license": "MIT",
"dependencies": {
"uuid": "^9.0.0",
@@ -33,7 +33,7 @@
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
- "zilaws-server": "^1.1.0"
+ "zilaws-server": "^1.1.2"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@@ -6689,9 +6689,9 @@
}
},
"node_modules/zilaws-server": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/zilaws-server/-/zilaws-server-1.1.0.tgz",
- "integrity": "sha512-7K8RxbrhV2bjz46Q3Fqt78FYFdaAqr264SFwcgKP0RhVdo1vjiT2aB5opbTLFD+WnDmIFUHlknM7JrwomKRCcw==",
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/zilaws-server/-/zilaws-server-1.1.2.tgz",
+ "integrity": "sha512-Wq3JeqJD86Vwj28A/C4MXUo5davDerGoMSQBZ65PH7S2iyUxKpJfg2LxqdVkkzHnMyE6W1AqpXUxwZQW9xVYzw==",
"dev": true,
"dependencies": {
"ws": "^8.13.0"
diff --git a/package.json b/package.json
index 5a3bd84..030c6c6 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "zilaws-client",
- "version": "1.1.3",
+ "version": "2.0.0",
"description": "ZilaWS is a blazingly fast and very lightweight library that provides an extremely easy-to-use way to transmit data via websockets between client-side and server-side using eventhandlers and async waiters.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
@@ -73,7 +73,7 @@
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
- "zilaws-server": "^1.1.0"
+ "zilaws-server": "^1.1.2"
},
"dependencies": {
"uuid": "^9.0.0",
diff --git a/src/index.ts b/src/index.ts
index e533066..a3f443c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -283,7 +283,7 @@ export class ZilaConnection {
resolve(
Promise.any([
- new Promise(r => {
+ new Promise((r) => {
this.setMessageHandler(uuid, (args: any[]): void => {
clearTimeout(timeout);
this.removeMessageHandler(uuid);
@@ -294,7 +294,7 @@ export class ZilaConnection {
timeout = setTimeout(() => {
_r(undefined);
}, this.maxWaiterTime);
- })
+ }),
]) as Promise
);
@@ -303,38 +303,38 @@ export class ZilaConnection {
}
/**
- * Calls an eventhandler on the server-side for the specified client. Gets a value of T type back from the client or just waits for the eventhandler to finish.
- * @param {string} identifier The callback's name on the client-side.
- * @param {number} maxWaitingTime The maximum time this waiter will wait for the client.
- * @param {any|undefined} data Arguments that shall be passed to the callback as parameters (optional)
- * @returns {Promise}
- */
- public waiterTimeout(identifier: string, maxWaitingTime: number, ...data: any[]): Promise {
- return new Promise(async (resolve) => {
- const uuid = randomUUID();
-
- let timeout: NodeJS.Timeout;
-
- resolve(
- Promise.any([
- new Promise(r => {
- this.setMessageHandler(uuid, (args: any[]): void => {
- clearTimeout(timeout);
- this.removeMessageHandler(uuid);
- r(args);
- });
- }),
- new Promise((_r) => {
- timeout = setTimeout(() => {
- _r(undefined);
- }, maxWaitingTime);
- })
- ]) as Promise
- );
-
- this.connection!.send(this.getMessageJSON(identifier, data, uuid));
- });
- }
+ * Calls an eventhandler on the server-side for the specified client. Gets a value of T type back from the client or just waits for the eventhandler to finish.
+ * @param {string} identifier The callback's name on the client-side.
+ * @param {number} maxWaitingTime The maximum time this waiter will wait for the client.
+ * @param {any|undefined} data Arguments that shall be passed to the callback as parameters (optional)
+ * @returns {Promise}
+ */
+ public waiterTimeout(identifier: string, maxWaitingTime: number, ...data: any[]): Promise {
+ return new Promise(async (resolve) => {
+ const uuid = randomUUID();
+
+ let timeout: NodeJS.Timeout;
+
+ resolve(
+ Promise.any([
+ new Promise((r) => {
+ this.setMessageHandler(uuid, (args: any[]): void => {
+ clearTimeout(timeout);
+ this.removeMessageHandler(uuid);
+ r(args);
+ });
+ }),
+ new Promise((_r) => {
+ timeout = setTimeout(() => {
+ _r(undefined);
+ }, maxWaitingTime);
+ }),
+ ]) as Promise
+ );
+
+ this.connection!.send(this.getMessageJSON(identifier, data, uuid));
+ });
+ }
/**
* Sync cookies to the server-side.
diff --git a/test/index.test.ts b/test/index.test.ts
index bd1f13e..e08d8b6 100644
--- a/test/index.test.ts
+++ b/test/index.test.ts
@@ -83,7 +83,7 @@ describe("WebSocket connection", () => {
test("Client Async WaiterTimeout", async () => {
server.setMessageHandler("WaiterTimeout", (socket, data: string) => {
- expect(data).toEqual("sampleData")
+ expect(data).toEqual("sampleData");
return data + " success";
});