File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 3
3
* automatically pop the bytes that have been already read.
4
4
*/
5
5
export default class DataReader {
6
- public readonly buffer : ArrayBuffer ;
6
+ private readonly bufferData : ArrayBuffer ;
7
7
private pointer : number = 0 ;
8
8
9
9
/**
10
10
* @param buffer The buffer to read from
11
11
*/
12
12
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 ;
14
23
}
15
24
16
25
/**
@@ -19,7 +28,7 @@ export default class DataReader {
19
28
* @returns The buffer that is left.
20
29
*/
21
30
public get bufferLeft ( ) : ArrayBuffer {
22
- return this . buffer . slice ( this . pointer ) ;
31
+ return this . bufferData . slice ( this . pointer ) ;
23
32
}
24
33
25
34
/**
@@ -29,7 +38,7 @@ export default class DataReader {
29
38
* @returns The value read by `readFunction`.
30
39
*/
31
40
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 )
33
42
this . pointer += bytes ;
34
43
return value ;
35
44
}
You can’t perform that action at this time.
0 commit comments