[Pkg-javascript-commits] [pdf.js] 153/210: Add isEmpty method to Stream, DecodeStream and ChunkedStream

David Prévot taffit at moszumanska.debian.org
Thu Jun 5 14:21:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch upstream
in repository pdf.js.

commit ea0453f106ecdb98e43bdfb8a0fa2c4cfb009f06
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sun May 18 00:31:47 2014 +0200

    Add isEmpty method to Stream, DecodeStream and ChunkedStream
---
 src/core/chunked_stream.js |  4 ++++
 src/core/stream.js         | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js
index 6c0c16d..8e40217 100644
--- a/src/core/chunked_stream.js
+++ b/src/core/chunked_stream.js
@@ -133,6 +133,10 @@ var ChunkedStream = (function ChunkedStreamClosure() {
       return this.end - this.start;
     },
 
+    get isEmpty() {
+      return this.length === 0;
+    },
+
     getByte: function ChunkedStream_getByte() {
       var pos = this.pos;
       if (pos >= this.end) {
diff --git a/src/core/stream.js b/src/core/stream.js
index a7d5d34..f2996a6 100644
--- a/src/core/stream.js
+++ b/src/core/stream.js
@@ -35,6 +35,9 @@ var Stream = (function StreamClosure() {
     get length() {
       return this.end - this.start;
     },
+    get isEmpty() {
+      return this.length === 0;
+    },
     getByte: function Stream_getByte() {
       if (this.pos >= this.end) {
         return -1;
@@ -128,6 +131,12 @@ var DecodeStream = (function DecodeStreamClosure() {
   }
 
   DecodeStream.prototype = {
+    get isEmpty() {
+      while (!this.eof && this.bufferLength === 0) {
+        this.readBlock();
+      }
+      return this.bufferLength === 0;
+    },
     ensureBuffer: function DecodeStream_ensureBuffer(requested) {
       var buffer = this.buffer;
       var current;
@@ -213,7 +222,7 @@ var DecodeStream = (function DecodeStreamClosure() {
       }
       return new Stream(this.buffer, start, length, dict);
     },
-    skip: function Stream_skip(n) {
+    skip: function DecodeStream_skip(n) {
       if (!n) {
         n = 1;
       }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list