Add peekByte method to Stream, DecodeStream and ChunkedStream
This commit is contained in:
parent
0674a3bd02
commit
d1974eae34
@ -195,6 +195,12 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
|||||||
return bytes.subarray(pos, end);
|
return bytes.subarray(pos, end);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
peekByte: function ChunkedStream_peekByte() {
|
||||||
|
var peekedByte = this.getByte();
|
||||||
|
this.pos--;
|
||||||
|
return peekedByte;
|
||||||
|
},
|
||||||
|
|
||||||
peekBytes: function ChunkedStream_peekBytes(length) {
|
peekBytes: function ChunkedStream_peekBytes(length) {
|
||||||
var bytes = this.getBytes(length);
|
var bytes = this.getBytes(length);
|
||||||
this.pos -= bytes.length;
|
this.pos -= bytes.length;
|
||||||
|
@ -478,7 +478,7 @@ var Lexer = (function LexerClosure() {
|
|||||||
return (this.currentChar = this.stream.getByte());
|
return (this.currentChar = this.stream.getByte());
|
||||||
},
|
},
|
||||||
peekChar: function Lexer_peekChar() {
|
peekChar: function Lexer_peekChar() {
|
||||||
return this.stream.peekBytes(1)[0];
|
return this.stream.peekByte();
|
||||||
},
|
},
|
||||||
getNumber: function Lexer_getNumber() {
|
getNumber: function Lexer_getNumber() {
|
||||||
var ch = this.currentChar;
|
var ch = this.currentChar;
|
||||||
|
@ -73,6 +73,11 @@ var Stream = (function StreamClosure() {
|
|||||||
this.pos = end;
|
this.pos = end;
|
||||||
return bytes.subarray(pos, end);
|
return bytes.subarray(pos, end);
|
||||||
},
|
},
|
||||||
|
peekByte: function Stream_peekByte() {
|
||||||
|
var peekedByte = this.getByte();
|
||||||
|
this.pos--;
|
||||||
|
return peekedByte;
|
||||||
|
},
|
||||||
peekBytes: function Stream_peekBytes(length) {
|
peekBytes: function Stream_peekBytes(length) {
|
||||||
var bytes = this.getBytes(length);
|
var bytes = this.getBytes(length);
|
||||||
this.pos -= bytes.length;
|
this.pos -= bytes.length;
|
||||||
@ -202,6 +207,11 @@ var DecodeStream = (function DecodeStreamClosure() {
|
|||||||
this.pos = end;
|
this.pos = end;
|
||||||
return this.buffer.subarray(pos, end);
|
return this.buffer.subarray(pos, end);
|
||||||
},
|
},
|
||||||
|
peekByte: function DecodeStream_peekByte() {
|
||||||
|
var peekedByte = this.getByte();
|
||||||
|
this.pos--;
|
||||||
|
return peekedByte;
|
||||||
|
},
|
||||||
peekBytes: function DecodeStream_peekBytes(length) {
|
peekBytes: function DecodeStream_peekBytes(length) {
|
||||||
var bytes = this.getBytes(length);
|
var bytes = this.getBytes(length);
|
||||||
this.pos -= bytes.length;
|
this.pos -= bytes.length;
|
||||||
@ -527,7 +537,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|||||||
var end = bufferLength + blockLen;
|
var end = bufferLength + blockLen;
|
||||||
this.bufferLength = end;
|
this.bufferLength = end;
|
||||||
if (blockLen === 0) {
|
if (blockLen === 0) {
|
||||||
if (str.peekBytes(1).length === 0) {
|
if (str.peekByte() === -1) {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user