Skip to content

Commit 914d58c

Browse files
authored
Merge pull request #5 from Kikorono/develop
Modularization, dependency updates, new package commands, and more ByteBuffer functionality
2 parents 4def99f + 61e9648 commit 914d58c

File tree

9 files changed

+460
-248
lines changed

9 files changed

+460
-248
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tsconfig.json
22
src
33
.idea
4-
test.*
4+
test.js
5+
test.ts

package-lock.json

Lines changed: 418 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
{
22
"name": "@runejs/common",
3-
"version": "2.0.0-rc.5",
3+
"version": "2.0.0-rc.9",
44
"description": "Common logging, networking, compression, and other functionality for RuneJS applications.",
5-
"main": "lib/index.js",
6-
"types": "lib/index.d.ts",
5+
"main": "./index.js",
6+
"types": "./index.d.ts",
7+
"exports": {
8+
".": "./index.js",
9+
"./buffer": "./buffer/index.js",
10+
"./color": "./color/index.js",
11+
"./compression": "./compression/index.js",
12+
"./fs": "./fs/index.js",
13+
"./logger": "./logger/index.js",
14+
"./net": "./net/index.js",
15+
"./util": "./util/index.js"
16+
},
717
"scripts": {
818
"build": "tsc",
919
"start": "ts-node src/test.ts",
1020
"lint": "eslint --ext .ts src",
1121
"lint:fix": "eslint --ext .ts src --fix",
12-
"copy-documents": "cp package.json lib && cp README.md lib && cp .npmignore lib && cp LICENSE lib",
13-
"copy-documents:windows": "copy package.json lib && copy README.md lib && copy .npmignore lib && copy LICENSE lib",
14-
"package": "rimraf lib && npm run build && npm run copy-documents && cd lib && npm publish --dry-run",
15-
"package:windows": "rimraf lib && npm run build && npm run copy-documents:windows && cd lib && npm publish --dry-run"
22+
"copy-documents": "copyfiles package.json README.md .npmignore LICENSE lib",
23+
"package": "rimraf lib && npm i && npm run build && npm run copy-documents && cd lib && npm publish --dry-run",
24+
"publish:next": "npm run package && cd lib && npm publish -tag next",
25+
"publish:beta": "npm run package && cd lib && npm publish -tag beta",
26+
"publish:rc": "npm run package && cd lib && npm publish -tag rc"
1627
},
1728
"repository": {
1829
"type": "git",
@@ -46,9 +57,10 @@
4657
"@types/pino": "^6.3.11",
4758
"@typescript-eslint/eslint-plugin": "^4.29.3",
4859
"@typescript-eslint/parser": "^4.29.3",
60+
"copyfiles": "^2.4.1",
4961
"eslint": "^7.32.0",
5062
"rimraf": "^3.0.2",
51-
"ts-node": "^10.3.0",
63+
"ts-node-dev": "^1.1.8",
5264
"typescript": "^4.4.4"
5365
},
5466
"eslintConfig": {

src/buffer/byte-buffer.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class ByteBuffer extends Uint8Array {
6060

6161
public readInt8: (offset: number) => number;
6262
public readUInt8: (offset: number) => number;
63-
public copy: (targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number) => number;
63+
public copy: (targetBuffer: Uint8Array | ByteBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number) => number;
6464

6565
private _writerIndex: number = 0;
6666
private _readerIndex: number = 0;
@@ -165,8 +165,21 @@ export class ByteBuffer extends Uint8Array {
165165
return null;
166166
}
167167

168-
public at(index: number, signed: Signedness = 'signed'): number {
169-
return ByteBuffer.getSignage(signed) === 'S' ? this.readInt8(index) : this.readUInt8(index);
168+
public at(index: number): number;
169+
public at(index: number, type: Extract<DataType, 'string' | 'STRING'>): string;
170+
public at(index: number, type: Extract<DataType, 'long' | 'LONG'>, signed?: Signedness, endian?: Endianness): bigint;
171+
public at(index: number, type: Exclude<DataType, 'string' | 'STRING' | 'long' | 'LONG'>, signed?: Signedness, endian?: Endianness): number;
172+
public at(index: number, type?: DataType, signed?: Signedness, endian?: Endianness): number | bigint | string;
173+
public at(index: number, type: DataType = 'byte', signed: Signedness = 'signed', endian: Endianness = 'be'): number | bigint | string {
174+
const readerIndex = this.readerIndex;
175+
this.readerIndex = index;
176+
177+
const value = this.get(type, signed, endian);
178+
179+
// Reset to the original reader index
180+
this.readerIndex = readerIndex;
181+
182+
return value;
170183
}
171184

172185
public getSlice(position: number, length: number): ByteBuffer {

src/encryption/file-encryption.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/encryption/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/encryption/xtea.ts

Lines changed: 0 additions & 153 deletions
This file was deleted.

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './logger';
2+
export * from './buffer';

tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
"esModuleInterop": true,
1010
"allowSyntheticDefaultImports": true,
1111
"sourceMap": true,
12-
"baseUrl": ".",
12+
"baseUrl": "./src",
1313
"allowJs": true,
1414
"declaration": true,
1515
"outDir": "./lib",
1616
"types": [
1717
"node"
1818
]
1919
},
20-
"include": [
21-
"src/**/*.ts"
22-
],
23-
"exclude": [
24-
"node_modules"
25-
]
20+
"include": [ "src/" ],
21+
"exclude": [ "!src/" ]
2622
}

0 commit comments

Comments
 (0)