mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Add isEmpty method to Stream, DecodeStream and ChunkedStream
This commit is contained in:
parent
c0419d7dea
commit
ea0453f106
2 changed files with 14 additions and 1 deletions
|
@ -133,6 +133,10 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
||||||
return this.end - this.start;
|
return this.end - this.start;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get isEmpty() {
|
||||||
|
return this.length === 0;
|
||||||
|
},
|
||||||
|
|
||||||
getByte: function ChunkedStream_getByte() {
|
getByte: function ChunkedStream_getByte() {
|
||||||
var pos = this.pos;
|
var pos = this.pos;
|
||||||
if (pos >= this.end) {
|
if (pos >= this.end) {
|
||||||
|
|
|
@ -35,6 +35,9 @@ var Stream = (function StreamClosure() {
|
||||||
get length() {
|
get length() {
|
||||||
return this.end - this.start;
|
return this.end - this.start;
|
||||||
},
|
},
|
||||||
|
get isEmpty() {
|
||||||
|
return this.length === 0;
|
||||||
|
},
|
||||||
getByte: function Stream_getByte() {
|
getByte: function Stream_getByte() {
|
||||||
if (this.pos >= this.end) {
|
if (this.pos >= this.end) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -128,6 +131,12 @@ var DecodeStream = (function DecodeStreamClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodeStream.prototype = {
|
DecodeStream.prototype = {
|
||||||
|
get isEmpty() {
|
||||||
|
while (!this.eof && this.bufferLength === 0) {
|
||||||
|
this.readBlock();
|
||||||
|
}
|
||||||
|
return this.bufferLength === 0;
|
||||||
|
},
|
||||||
ensureBuffer: function DecodeStream_ensureBuffer(requested) {
|
ensureBuffer: function DecodeStream_ensureBuffer(requested) {
|
||||||
var buffer = this.buffer;
|
var buffer = this.buffer;
|
||||||
var current;
|
var current;
|
||||||
|
@ -213,7 +222,7 @@ var DecodeStream = (function DecodeStreamClosure() {
|
||||||
}
|
}
|
||||||
return new Stream(this.buffer, start, length, dict);
|
return new Stream(this.buffer, start, length, dict);
|
||||||
},
|
},
|
||||||
skip: function Stream_skip(n) {
|
skip: function DecodeStream_skip(n) {
|
||||||
if (!n) {
|
if (!n) {
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue