Skip to content

Commit 239aaf9

Browse files
committed
Update data_reader.ts
1 parent bfbf425 commit 239aaf9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/data_reader.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@
33
* automatically pop the bytes that have been already read.
44
*/
55
export default class DataReader {
6-
public readonly buffer : ArrayBuffer;
6+
private readonly bufferData : ArrayBuffer;
77
private pointer : number = 0;
88

99
/**
1010
* @param buffer The buffer to read from
1111
*/
1212
constructor(buffer : ArrayBuffer) {
13-
this.buffer = buffer;
13+
this.bufferData = buffer;
14+
}
15+
16+
/**
17+
* This getter returns the whole buffer.
18+
*
19+
* @returns The whole buffer.
20+
*/
21+
public get buffer() : ArrayBuffer {
22+
return this.bufferData;
1423
}
1524

1625
/**
@@ -19,7 +28,7 @@ export default class DataReader {
1928
* @returns The buffer that is left.
2029
*/
2130
public get bufferLeft() : ArrayBuffer {
22-
return this.buffer.slice(this.pointer);
31+
return this.bufferData.slice(this.pointer);
2332
}
2433

2534
/**
@@ -29,7 +38,7 @@ export default class DataReader {
2938
* @returns The value read by `readFunction`.
3039
*/
3140
public read(bytes : number = 1) : ArrayBuffer {
32-
const value = this.buffer.slice(this.pointer, this.pointer + bytes)
41+
const value = this.bufferData.slice(this.pointer, this.pointer + bytes)
3342
this.pointer += bytes;
3443
return value;
3544
}

0 commit comments

Comments
 (0)