Skip to content

Commit

Permalink
rc.5: updating to TypeScript 4.4, tslib 2.3, and adding more overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynarus committed Oct 13, 2021
1 parent 2da72d5 commit 4def99f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 48 deletions.
109 changes: 73 additions & 36 deletions package-lock.json

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

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runejs/common",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.5",
"description": "Common logging, networking, compression, and other functionality for RuneJS applications.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -29,12 +29,16 @@
"url": "https://github.com/runejs/core/issues"
},
"homepage": "https://github.com/runejs/core#readme",
"peerDependencies": {
"tslib": ">=2.3.0",
"typescript": ">=4.4.0"
},
"dependencies": {
"compressjs": "^1.0.3",
"js-yaml": "^3.14.1",
"pino": "^6.13.0",
"pino-pretty": "^4.8.0",
"tslib": ">=2.1.0"
"tslib": "^2.3.1"
},
"devDependencies": {
"@runejs/eslint-config": "^1.0.0",
Expand All @@ -44,11 +48,8 @@
"@typescript-eslint/parser": "^4.29.3",
"eslint": "^7.32.0",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"typescript": ">=4.2.0"
},
"peerDependencies": {
"tslib": ">=2.1.0"
"ts-node": "^10.3.0",
"typescript": "^4.4.4"
},
"eslintConfig": {
"extends": [
Expand Down
1 change: 1 addition & 0 deletions src/buffer/byte-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class ByteBuffer extends Uint8Array {
public get(type: Extract<DataType, 'string' | 'STRING'>): string;
public get(type: Extract<DataType, 'long' | 'LONG'>, signed?: Signedness, endian?: Endianness): bigint;
public get(type: Exclude<DataType, 'string' | 'STRING' | 'long' | 'LONG'>, signed?: Signedness, endian?: Endianness): number;
public get(type?: DataType, signed?: Signedness, endian?: Endianness): number | bigint | string;
public get(type: DataType = 'byte', signed: Signedness = 'signed', endian: Endianness = 'be'): number | bigint | string {
type = ByteBuffer.getType(type);
signed = ByteBuffer.getSignage(signed);
Expand Down
17 changes: 12 additions & 5 deletions src/net/socket-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,22 @@ export abstract class SocketServer<T = undefined> {
this.connectionDestroyed();
}

public error(error: any): void {
logger.error('Socket destroyed due to error:');
logger.error(error);
public error(error: Error): void;
public error(error: { message?: string }): void;
public error(error: string): void;
public error(error: any | Error | { message?: string } | string): void;
public error(error: any | Error | { message?: string } | string): void {
if(error && typeof error === 'string') {
error = { message: error };
}

logger.error('Socket destroyed due to error' + error?.message ? `: ${error.message}` : '.');

try {
this.closeConnection();
} catch(closeConnectionError) {
logger.error(`Error closing server connection:`);
logger.error(closeConnectionError);
logger.error('Error closing server connection' +
closeConnectionError?.message ? `: ${closeConnectionError.message}` : '.');
}
}

Expand Down

0 comments on commit 4def99f

Please sign in to comment.