@@ -66,6 +66,11 @@ export class ByteStream {
6666 this . littleEndian_ = true ;
6767 }
6868
69+ /** @returns {boolean } Whether the stream is little-endian. */
70+ isLittleEndian ( ) {
71+ return this . littleEndian_ ;
72+ }
73+
6974 /** Big-Endian is sometimes called Motorola-style. */
7075 setBigEndian ( ) {
7176 this . littleEndian_ = false ;
@@ -78,13 +83,15 @@ export class ByteStream {
7883
7984 /**
8085 * Returns how many bytes have been read in the stream since the beginning of time.
86+ * @returns {number }
8187 */
8288 getNumBytesRead ( ) {
8389 return this . bytesRead_ ;
8490 }
8591
8692 /**
8793 * Returns how many bytes are currently in the stream left to be read.
94+ * @returns {number }
8895 */
8996 getNumBytesLeft ( ) {
9097 const bytesInCurrentPage = ( this . bytes . byteLength - this . ptr ) ;
@@ -334,6 +341,10 @@ export class ByteStream {
334341
335342 /**
336343 * Creates a new ByteStream from this ByteStream that can be read / peeked.
344+ * Note that the teed stream is a disconnected copy. If you push more bytes to the original
345+ * stream, the copy does not get them.
346+ * TODO: Assess whether the above causes more bugs than it avoids. (It would feel weird to me if
347+ * the teed stream shared some state with the original stream.)
337348 * @returns {ByteStream } A clone of this ByteStream.
338349 */
339350 tee ( ) {
@@ -342,6 +353,7 @@ export class ByteStream {
342353 clone . ptr = this . ptr ;
343354 clone . pages_ = this . pages_ . slice ( ) ;
344355 clone . bytesRead_ = this . bytesRead_ ;
356+ clone . littleEndian_ = this . littleEndian_ ;
345357 return clone ;
346358 }
347359}
0 commit comments