mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: deploy new compression
This commit is contained in:
1 parent
1575b803c0
commit
63084d1855
10 files changed
+10312
-6090
No files matched your search
@@ -40,21 +40,25 @@ export class BkonReadStream extends ReadStream {
|
||||
this.magic();
|
||||
const header = this.header();
|
||||
const body = this.body(header.fastStringFormat, header.stringTable);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
magic() {
|
||||
if (this.ascii(4) !== 'BKON') {
|
||||
throw new Error('Invalid BKON magic number');
|
||||
const magic = this.ascii(4);
|
||||
|
||||
if (magic !== 'BKON') {
|
||||
throw new Error(`Invalid Bkon magic number: "${magic}"`);
|
||||
}
|
||||
}
|
||||
|
||||
header() {
|
||||
const version = this.uint16();
|
||||
const fastStringFormat = this.uint8() as FastStringFormat;
|
||||
|
||||
return {
|
||||
version: this.uint16(),
|
||||
fastStringFormat: this.uint8() as FastStringFormat,
|
||||
stringTable: this.stringTable(),
|
||||
version,
|
||||
fastStringFormat,
|
||||
stringTable: this.stringTable(fastStringFormat),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,8 +69,23 @@ export class BkonReadStream extends ReadStream {
|
||||
return this.value(fastStringFormat, stringTable);
|
||||
}
|
||||
|
||||
stringTable() {
|
||||
const count = this.uint16();
|
||||
stringTable(fastStringFormat: FastStringFormat) {
|
||||
let count: number;
|
||||
|
||||
switch (fastStringFormat) {
|
||||
case FastStringFormat.Format8:
|
||||
count = this.uint8();
|
||||
break;
|
||||
|
||||
case FastStringFormat.Format16:
|
||||
count = this.uint16();
|
||||
break;
|
||||
|
||||
case FastStringFormat.Format32:
|
||||
count = this.uint32();
|
||||
break;
|
||||
}
|
||||
|
||||
const strings: string[] = [];
|
||||
|
||||
for (let index = 0; index < count; index++) {
|
||||
|
||||
Reference in new issue
Block a user