allow getting the writer offset and the length of both readers and writers
This commit is contained in:
parent
63a3e5c73b
commit
c1e43e2937
3 changed files with 13 additions and 1 deletions
|
@ -14,6 +14,10 @@ export class ReaderBase {
|
||||||
return this.offset;
|
return this.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get length() {
|
||||||
|
return this.buffer.length;
|
||||||
|
}
|
||||||
|
|
||||||
public readBuffer(bytes:number) {
|
public readBuffer(bytes:number) {
|
||||||
const value = this.buffer.subarray(this.offset, this.offset + bytes);
|
const value = this.buffer.subarray(this.offset, this.offset + bytes);
|
||||||
this.offset += bytes;
|
this.offset += bytes;
|
||||||
|
|
|
@ -14,6 +14,14 @@ export class WriterBase {
|
||||||
this.resizable = size === 0;
|
this.resizable = size === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get writeOffset() {
|
||||||
|
return this.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get length() {
|
||||||
|
return this.buffer.length;
|
||||||
|
}
|
||||||
|
|
||||||
public toBuffer() {
|
public toBuffer() {
|
||||||
return this.buffer;
|
return this.buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bufferstuff",
|
"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",
|
"description": "A set of utility classes for reading and writing binary data in NodeJS and the browser",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|
Loading…
Reference in a new issue