allow getting the writer offset and the length of both readers and writers

This commit is contained in:
Holly Stubbs 2023-11-07 00:14:03 +00:00
parent 63a3e5c73b
commit c1e43e2937
Signed by: tgpholly
GPG Key ID: B8583C4B7D18119E
3 changed files with 13 additions and 1 deletions

View File

@ -14,6 +14,10 @@ export class ReaderBase {
return this.offset;
}
public get length() {
return this.buffer.length;
}
public readBuffer(bytes:number) {
const value = this.buffer.subarray(this.offset, this.offset + bytes);
this.offset += bytes;

View File

@ -14,6 +14,14 @@ export class WriterBase {
this.resizable = size === 0;
}
public get writeOffset() {
return this.offset;
}
public get length() {
return this.buffer.length;
}
public toBuffer() {
return this.buffer;
}

View File

@ -1,6 +1,6 @@
{
"name": "bufferstuff",
"version": "1.4.0",
"version": "1.4.1",
"description": "A set of utility classes for reading and writing binary data in NodeJS and the browser",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",