Skip to content

Commit c1e43e2

Browse files
committed
allow getting the writer offset and the length of both readers and writers
1 parent 63a3e5c commit c1e43e2

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

base/ReaderBase.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export class ReaderBase {
1414
return this.offset;
1515
}
1616

17+
public get length() {
18+
return this.buffer.length;
19+
}
20+
1721
public readBuffer(bytes:number) {
1822
const value = this.buffer.subarray(this.offset, this.offset + bytes);
1923
this.offset += bytes;

base/WriterBase.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ export class WriterBase {
1414
this.resizable = size === 0;
1515
}
1616

17+
public get writeOffset() {
18+
return this.offset;
19+
}
20+
21+
public get length() {
22+
return this.buffer.length;
23+
}
24+
1725
public toBuffer() {
1826
return this.buffer;
1927
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bufferstuff",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A set of utility classes for reading and writing binary data in NodeJS and the browser",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

0 commit comments

Comments
 (0)