Skip to content

Commit

Permalink
2.0.0. Release
Browse files Browse the repository at this point in the history
  • Loading branch information
WarstekHUN committed Dec 24, 2023
1 parent dd1f82a commit 8ee114d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .coverage-badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .coverage-badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .coverage-badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 1 addition & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,4 @@ jobs:
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publishGHP:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .npmrc file to publish to GitHub Packages
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@zilaws'
- name: Install modules
run: npm ci
- name: Build and generate coverage badges
run: npm run build
- name: Publish to GitHub Packages
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.PAT }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
68 changes: 34 additions & 34 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -294,7 +294,7 @@ export class ZilaConnection {
timeout = setTimeout(() => {
_r(undefined);
}, this.maxWaiterTime);
})
}),
]) as Promise<T | undefined>
);

Expand All @@ -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<T | undefined>}
*/
public waiterTimeout<T>(identifier: string, maxWaitingTime: number, ...data: any[]): Promise<T | undefined> {
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<T | undefined>
);
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<T | undefined>}
*/
public waiterTimeout<T>(identifier: string, maxWaitingTime: number, ...data: any[]): Promise<T | undefined> {
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<T | undefined>
);

this.connection!.send(this.getMessageJSON(identifier, data, uuid));
});
}

/**
* Sync cookies to the server-side.
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
});

Expand Down

0 comments on commit 8ee114d

Please sign in to comment.