File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -69,13 +69,16 @@ the byte stream by using `someByteStream.push(nextBytesAsAnArrayBuffer)`.
6969
7070If you have a need to seek ahead to a different section of the stream of bytes, and want to later
7171return to where you left off, you should use ` tee() ` method to make a copy of the ByteStream. This
72- will let you seek to the appropriate spot to grab some bytes.
72+ will let you seek to the appropriate spot to grab some bytes using the teed stream, while you can
73+ pick up where you left off with the original stream.
7374
7475``` javascript
75- const byteStream = new ByteStream (someArrayBuffer);
76- const strLen = byteStream .readNumber (4 ); // Bytes 0-3.
77- const strOffset = byteStream .readNumber (4 ); // Bytes 4-7.
78- // Grab bytes at that offset...
79- const description = byteStream .tee ().skip (offset).readString (strLen);
80- const someOtherVal = byteStream .readNumber (4 ); // Bytes 8-11
76+ const origStream = new ByteStream (someArrayBuffer);
77+ const strLen = origStream .readNumber (4 ); // Bytes 0-3.
78+ const strOffset = origStream .readNumber (4 ); // Bytes 4-7.
79+
80+ const teedStream = origStream .tee ();
81+ const description = teedStream .skip (strOffset).readString (strLen);
82+
83+ const someOtherVal = origStream .readNumber (4 ); // Bytes 8-11
8184```
You can’t perform that action at this time.
0 commit comments