From 0466c9216ed7809e76cdbdbfcaea845e66b06923 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 15 Mar 2023 21:23:07 +0100 Subject: [PATCH 01/15] remove unneeded typecast --- types/array/array.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/array/array.ts b/types/array/array.ts index a5889c7..7fb03b3 100644 --- a/types/array/array.ts +++ b/types/array/array.ts @@ -57,6 +57,6 @@ export class ArrayType implements SizedType, ViewableType { }); } - return array as T[]; + return array; } } From bf66d6bf6121152e3cdd91b25c9b154b105a30b3 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 15 Mar 2023 21:23:46 +0100 Subject: [PATCH 02/15] fix: Bug when buffer is split into multiple views --- types/string/mod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/string/mod.ts b/types/string/mod.ts index 576a9c8..be91b26 100644 --- a/types/string/mod.ts +++ b/types/string/mod.ts @@ -12,14 +12,14 @@ export class FixedUTF8String implements SizedType { read(dataView: DataView, byteOffset = 0): string { return decoder.decode( - new Uint8Array(dataView.buffer, byteOffset, byteOffset + this.byteLength), + new Uint8Array(dataView.buffer, byteOffset + dataView.byteOffset, this.byteLength - byteOffset), ); } write(value: string, dataView: DataView, byteOffset = 0) { encoder.encodeInto( value, - new Uint8Array(dataView.buffer, byteOffset, this.byteLength), + new Uint8Array(dataView.buffer, byteOffset + dataView.byteOffset, this.byteLength - byteOffset), ); } } From 1ecf8aa230ddc7b9447661b1373e3978c0546566 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 15 Mar 2023 21:29:25 +0100 Subject: [PATCH 03/15] actually fix shit --- types/string/fixed_length.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/string/fixed_length.ts b/types/string/fixed_length.ts index 1c2e4cf..3fbd754 100644 --- a/types/string/fixed_length.ts +++ b/types/string/fixed_length.ts @@ -12,14 +12,14 @@ export class FixedLengthString implements SizedType { read(dataView: DataView, byteOffset = 0): string { return decoder.decode( - new Uint8Array(dataView.buffer, byteOffset, byteOffset + this.byteLength), + new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, this.byteLength - byteOffset), ); } write(value: string, dataView: DataView, byteOffset = 0) { encoder.encodeInto( value, - new Uint8Array(dataView.buffer, byteOffset, this.byteLength), + new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, this.byteLength - byteOffset), ); } } From 6c0f3e936dd1df24fed62779704f5e0c6538e918 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 15 Mar 2023 22:06:43 +0100 Subject: [PATCH 04/15] fmt --- types/string/fixed_length.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/types/string/fixed_length.ts b/types/string/fixed_length.ts index 3fbd754..035e743 100644 --- a/types/string/fixed_length.ts +++ b/types/string/fixed_length.ts @@ -12,14 +12,22 @@ export class FixedLengthString implements SizedType { read(dataView: DataView, byteOffset = 0): string { return decoder.decode( - new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, this.byteLength - byteOffset), + new Uint8Array( + dataView.buffer, + dataView.byteOffset + byteOffset, + this.byteLength - byteOffset, + ), ); } write(value: string, dataView: DataView, byteOffset = 0) { encoder.encodeInto( value, - new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, this.byteLength - byteOffset), + new Uint8Array( + dataView.buffer, + dataView.byteOffset + byteOffset, + this.byteLength - byteOffset, + ), ); } } From 817f5b2a967f68cd3a6032bbd3628ec2eea522f8 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 12 Apr 2023 21:25:33 +0200 Subject: [PATCH 05/15] add varint --- types/varint/mod.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 types/varint/mod.ts diff --git a/types/varint/mod.ts b/types/varint/mod.ts new file mode 100644 index 0000000..ddbf465 --- /dev/null +++ b/types/varint/mod.ts @@ -0,0 +1,39 @@ +import { Type } from "../types.ts"; + +const SEGMENT_BITS = 0x7F; +const CONTINUE_BIT = 0x80; + +export class Leb128Varint implements Type { + read(dataView: DataView, byteOffset = 0): number { + let value = 0, position = 0; + while (true) { + const currentByte = dataView.getInt8(byteOffset); + value |= (currentByte & SEGMENT_BITS) << position; + + if ((currentByte & CONTINUE_BIT) === 0) break; + + position += 7; + byteOffset++; + + if (position >= 32) { + console.log(position); + throw new Error("VarInt is too big"); + } + } + + return value; + } + + write(value: number, dataView: DataView, byteOffset = 0): void { + while (true) { + if ((value & ~SEGMENT_BITS) === 0) { + dataView.setInt8(byteOffset, value); + return; + } + + dataView.setInt8(byteOffset, value & SEGMENT_BITS | CONTINUE_BIT); + byteOffset++; + value >>>= 7; + } + } +} From d07db3b6a9760867f5dc47b1ff3dd4f383339497 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 12 Apr 2023 21:25:52 +0200 Subject: [PATCH 06/15] x --- types/varint/mod.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/varint/mod.ts b/types/varint/mod.ts index ddbf465..bb126f5 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -37,3 +37,5 @@ export class Leb128Varint implements Type { } } } + +export const leb128Varint = new Leb128Varint(); \ No newline at end of file From 691629134efb74a9c0cc9ff6c7cbda2ec085e59c Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 12 Apr 2023 21:25:56 +0200 Subject: [PATCH 07/15] add tests --- types/varint/mod_test.ts | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 types/varint/mod_test.ts diff --git a/types/varint/mod_test.ts b/types/varint/mod_test.ts new file mode 100644 index 0000000..f622713 --- /dev/null +++ b/types/varint/mod_test.ts @@ -0,0 +1,72 @@ +import { Leb128Varint } from "./mod.ts"; +import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts"; + +Deno.test({ + name: "Read Positive varint", + fn: () => { + let data = Uint8Array.of(127); + let result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, 127); + + data = Uint8Array.of(128, 1); + result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, 128); + + data = Uint8Array.of(221, 199, 1); + result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, 25565); + + data = Uint8Array.of(255, 255, 255, 255, 7); + result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, 2147483647); + }, +}); + +Deno.test({ + name: "Read Negative varint", + fn: () => { + let data = Uint8Array.of(255, 255, 255, 255, 15); + let result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, -1); + + data = Uint8Array.of(128, 128, 128, 128, 8); + result = new Leb128Varint().read(new DataView(data.buffer)); + assertEquals(result, -2147483648); + }, +}); + +Deno.test({ + name: "Write Positive varint", + fn: () => { + let data = new Uint8Array(1); + new Leb128Varint().write(127, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(127)); + + data = new Uint8Array(2); + new Leb128Varint().write(128, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(128, 1)); + + + data = new Uint8Array(3); + new Leb128Varint().write(25565, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(221, 199, 1)); + + + data = new Uint8Array(5); + new Leb128Varint().write(2147483647, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(255, 255, 255, 255, 7)); + }, +}); + +Deno.test({ + name: "Write Negative varint", + fn: () => { + let data = new Uint8Array(5); + new Leb128Varint().write(-1, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(255, 255, 255, 255, 15)); + + data = new Uint8Array(5); + new Leb128Varint().write(-2147483648, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(128, 128, 128, 128, 8)); + }, +}); From f6cc05518863dd7dd46421f0678d384407a0fad8 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 12 Apr 2023 21:27:56 +0200 Subject: [PATCH 08/15] fmt --- types/varint/mod.ts | 2 +- types/varint/mod_test.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/varint/mod.ts b/types/varint/mod.ts index bb126f5..08e0bcf 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -38,4 +38,4 @@ export class Leb128Varint implements Type { } } -export const leb128Varint = new Leb128Varint(); \ No newline at end of file +export const leb128Varint = new Leb128Varint(); diff --git a/types/varint/mod_test.ts b/types/varint/mod_test.ts index f622713..662e0ad 100644 --- a/types/varint/mod_test.ts +++ b/types/varint/mod_test.ts @@ -46,12 +46,10 @@ Deno.test({ new Leb128Varint().write(128, new DataView(data.buffer)); assertEquals(data, Uint8Array.of(128, 1)); - data = new Uint8Array(3); new Leb128Varint().write(25565, new DataView(data.buffer)); assertEquals(data, Uint8Array.of(221, 199, 1)); - data = new Uint8Array(5); new Leb128Varint().write(2147483647, new DataView(data.buffer)); assertEquals(data, Uint8Array.of(255, 255, 255, 255, 7)); From 8ae6735a839d3790c0cf4b581c0e7df2f8ec788c Mon Sep 17 00:00:00 2001 From: MierenManz Date: Wed, 12 Apr 2023 21:52:31 +0200 Subject: [PATCH 09/15] remove console.log --- types/varint/mod.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/varint/mod.ts b/types/varint/mod.ts index 08e0bcf..1021a15 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -16,7 +16,6 @@ export class Leb128Varint implements Type { byteOffset++; if (position >= 32) { - console.log(position); throw new Error("VarInt is too big"); } } From e64b56737ab33904b0de4fa59306275e783cfc51 Mon Sep 17 00:00:00 2001 From: Skye <63878374+MierenManz@users.noreply.github.com> Date: Thu, 20 Apr 2023 21:25:47 +0200 Subject: [PATCH 10/15] Update types/varint/mod.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Elias Sjögreen --- types/varint/mod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/varint/mod.ts b/types/varint/mod.ts index 1021a15..e88edf8 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -16,7 +16,7 @@ export class Leb128Varint implements Type { byteOffset++; if (position >= 32) { - throw new Error("VarInt is too big"); + throw new TypeError("VarInt is too big"); } } From 06a7768ea5aea2c2334729e080734d75f941ce32 Mon Sep 17 00:00:00 2001 From: Skye <63878374+MierenManz@users.noreply.github.com> Date: Thu, 20 Apr 2023 21:25:58 +0200 Subject: [PATCH 11/15] Update types/varint/mod.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Elias Sjögreen --- types/varint/mod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/varint/mod.ts b/types/varint/mod.ts index e88edf8..789b141 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -37,4 +37,4 @@ export class Leb128Varint implements Type { } } -export const leb128Varint = new Leb128Varint(); +export const i32leb128 = new I32LEB128(); From b366965420b78e9c196e151960df6e249b1f1c5f Mon Sep 17 00:00:00 2001 From: MierenManz Date: Thu, 20 Apr 2023 21:32:44 +0200 Subject: [PATCH 12/15] rename file --- types/varint/leb128.ts | 40 ++++++++++++++++++++++++++++++++++++++++ types/varint/mod.ts | 41 +---------------------------------------- 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 types/varint/leb128.ts diff --git a/types/varint/leb128.ts b/types/varint/leb128.ts new file mode 100644 index 0000000..3b5556a --- /dev/null +++ b/types/varint/leb128.ts @@ -0,0 +1,40 @@ +import { Type } from "../types.ts"; + +const SEGMENT_BITS = 0x7F; +const CONTINUE_BIT = 0x80; + +export class I32LEB128 implements Type { + read(dataView: DataView, byteOffset = 0): number { + let value = 0, position = 0; + while (true) { + const currentByte = dataView.getInt8(byteOffset); + value |= (currentByte & SEGMENT_BITS) << position; + + if ((currentByte & CONTINUE_BIT) === 0) break; + + position += 7; + byteOffset++; + + if (position >= 32) { + throw new Error("VarInt is too big"); + } + } + + return value; + } + + write(value: number, dataView: DataView, byteOffset = 0): void { + while (true) { + if ((value & ~SEGMENT_BITS) === 0) { + dataView.setInt8(byteOffset, value); + return; + } + + dataView.setInt8(byteOffset, value & SEGMENT_BITS | CONTINUE_BIT); + byteOffset++; + value >>>= 7; + } + } +} + +export const i32leb128 = new I32LEB128(); diff --git a/types/varint/mod.ts b/types/varint/mod.ts index 789b141..5b0fe09 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -1,40 +1 @@ -import { Type } from "../types.ts"; - -const SEGMENT_BITS = 0x7F; -const CONTINUE_BIT = 0x80; - -export class Leb128Varint implements Type { - read(dataView: DataView, byteOffset = 0): number { - let value = 0, position = 0; - while (true) { - const currentByte = dataView.getInt8(byteOffset); - value |= (currentByte & SEGMENT_BITS) << position; - - if ((currentByte & CONTINUE_BIT) === 0) break; - - position += 7; - byteOffset++; - - if (position >= 32) { - throw new TypeError("VarInt is too big"); - } - } - - return value; - } - - write(value: number, dataView: DataView, byteOffset = 0): void { - while (true) { - if ((value & ~SEGMENT_BITS) === 0) { - dataView.setInt8(byteOffset, value); - return; - } - - dataView.setInt8(byteOffset, value & SEGMENT_BITS | CONTINUE_BIT); - byteOffset++; - value >>>= 7; - } - } -} - -export const i32leb128 = new I32LEB128(); +export * from "./leb128.ts"; \ No newline at end of file From 7bd5bab3ed925b296484c2ba79327a7193b26083 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Thu, 20 Apr 2023 21:32:53 +0200 Subject: [PATCH 13/15] more tests --- types/varint/leb128_test.ts | 91 +++++++++++++++++++++++++++++++++++++ types/varint/mod_test.ts | 70 ---------------------------- 2 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 types/varint/leb128_test.ts delete mode 100644 types/varint/mod_test.ts diff --git a/types/varint/leb128_test.ts b/types/varint/leb128_test.ts new file mode 100644 index 0000000..545a29d --- /dev/null +++ b/types/varint/leb128_test.ts @@ -0,0 +1,91 @@ +import { I32LEB128 } from "./mod.ts"; +import { assertEquals, assertThrows } from "https://deno.land/std@0.183.0/testing/asserts.ts"; + +Deno.test({ + name: "Read Positive varint", + fn: () => { + let data = Uint8Array.of(127); + let result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, 127); + + data = Uint8Array.of(128, 1); + result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, 128); + + data = Uint8Array.of(221, 199, 1); + result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, 25565); + + data = Uint8Array.of(255, 255, 255, 255, 7); + result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, 2147483647); + }, +}); + +Deno.test({ + name: "Read Negative varint", + fn: () => { + let data = Uint8Array.of(255, 255, 255, 255, 15); + let result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, -1); + + data = Uint8Array.of(128, 128, 128, 128, 8); + result = new I32LEB128().read(new DataView(data.buffer)); + assertEquals(result, -2147483648); + }, +}); + +Deno.test({ + name: "Read Bad varint", + fn: () => { + const data = Uint8Array.of(255, 255, 255, 255, 255, 15); + assertThrows(() => new I32LEB128().read(new DataView(data.buffer))) + }, +}); + +Deno.test({ + name: "Write Positive varint", + fn: () => { + let data = new Uint8Array(1); + new I32LEB128().write(127, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(127)); + + data = new Uint8Array(2); + new I32LEB128().write(128, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(128, 1)); + + data = new Uint8Array(3); + new I32LEB128().write(25565, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(221, 199, 1)); + + data = new Uint8Array(5); + new I32LEB128().write(2147483647, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(255, 255, 255, 255, 7)); + }, +}); + +Deno.test({ + name: "Write Negative varint", + fn: () => { + let data = new Uint8Array(5); + new I32LEB128().write(-1, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(255, 255, 255, 255, 15)); + + data = new Uint8Array(5); + new I32LEB128().write(-2147483648, new DataView(data.buffer)); + assertEquals(data, Uint8Array.of(128, 128, 128, 128, 8)); + }, +}); + +Deno.test({ + name: "Write & read i32 MAX", + fn: () => { + const value = 2_147_483_647; + const decoder = new I32LEB128(); + const bytes = new Uint8Array(5); + const dt = new DataView(bytes.buffer); + decoder.write(value, dt, 0); + const decodedValue = decoder.read(dt); + assertEquals(decodedValue, value); + } +}) \ No newline at end of file diff --git a/types/varint/mod_test.ts b/types/varint/mod_test.ts deleted file mode 100644 index 662e0ad..0000000 --- a/types/varint/mod_test.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { Leb128Varint } from "./mod.ts"; -import { assertEquals } from "https://deno.land/std@0.183.0/testing/asserts.ts"; - -Deno.test({ - name: "Read Positive varint", - fn: () => { - let data = Uint8Array.of(127); - let result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, 127); - - data = Uint8Array.of(128, 1); - result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, 128); - - data = Uint8Array.of(221, 199, 1); - result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, 25565); - - data = Uint8Array.of(255, 255, 255, 255, 7); - result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, 2147483647); - }, -}); - -Deno.test({ - name: "Read Negative varint", - fn: () => { - let data = Uint8Array.of(255, 255, 255, 255, 15); - let result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, -1); - - data = Uint8Array.of(128, 128, 128, 128, 8); - result = new Leb128Varint().read(new DataView(data.buffer)); - assertEquals(result, -2147483648); - }, -}); - -Deno.test({ - name: "Write Positive varint", - fn: () => { - let data = new Uint8Array(1); - new Leb128Varint().write(127, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(127)); - - data = new Uint8Array(2); - new Leb128Varint().write(128, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(128, 1)); - - data = new Uint8Array(3); - new Leb128Varint().write(25565, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(221, 199, 1)); - - data = new Uint8Array(5); - new Leb128Varint().write(2147483647, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(255, 255, 255, 255, 7)); - }, -}); - -Deno.test({ - name: "Write Negative varint", - fn: () => { - let data = new Uint8Array(5); - new Leb128Varint().write(-1, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(255, 255, 255, 255, 15)); - - data = new Uint8Array(5); - new Leb128Varint().write(-2147483648, new DataView(data.buffer)); - assertEquals(data, Uint8Array.of(128, 128, 128, 128, 8)); - }, -}); From cf2a1b4ae51ffa0ef16d86c200281db9013968e2 Mon Sep 17 00:00:00 2001 From: MierenManz Date: Thu, 20 Apr 2023 21:34:16 +0200 Subject: [PATCH 14/15] fmt --- types/varint/leb128_test.ts | 11 +++++++---- types/varint/mod.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/types/varint/leb128_test.ts b/types/varint/leb128_test.ts index 545a29d..35b455a 100644 --- a/types/varint/leb128_test.ts +++ b/types/varint/leb128_test.ts @@ -1,5 +1,8 @@ import { I32LEB128 } from "./mod.ts"; -import { assertEquals, assertThrows } from "https://deno.land/std@0.183.0/testing/asserts.ts"; +import { + assertEquals, + assertThrows, +} from "https://deno.land/std@0.183.0/testing/asserts.ts"; Deno.test({ name: "Read Positive varint", @@ -39,7 +42,7 @@ Deno.test({ name: "Read Bad varint", fn: () => { const data = Uint8Array.of(255, 255, 255, 255, 255, 15); - assertThrows(() => new I32LEB128().read(new DataView(data.buffer))) + assertThrows(() => new I32LEB128().read(new DataView(data.buffer))); }, }); @@ -87,5 +90,5 @@ Deno.test({ decoder.write(value, dt, 0); const decodedValue = decoder.read(dt); assertEquals(decodedValue, value); - } -}) \ No newline at end of file + }, +}); diff --git a/types/varint/mod.ts b/types/varint/mod.ts index 5b0fe09..53fea10 100644 --- a/types/varint/mod.ts +++ b/types/varint/mod.ts @@ -1 +1 @@ -export * from "./leb128.ts"; \ No newline at end of file +export * from "./leb128.ts"; From b714e6447c1a5a1be9e4fd946b6937c4e2ab9f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6green?= Date: Fri, 21 Apr 2023 10:41:28 +0200 Subject: [PATCH 15/15] fix: more descriptive error --- types/varint/leb128.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/varint/leb128.ts b/types/varint/leb128.ts index 3b5556a..3a93921 100644 --- a/types/varint/leb128.ts +++ b/types/varint/leb128.ts @@ -16,7 +16,7 @@ export class I32LEB128 implements Type { byteOffset++; if (position >= 32) { - throw new Error("VarInt is too big"); + throw new TypeError("I32LEB128 cannot exceed 32 bits in length"); } }