[Pkg-javascript-commits] [pdf.js] 65/204: Add peekByte method to Stream, DecodeStream and ChunkedStream
David Prévot
taffit at moszumanska.debian.org
Sat Oct 25 18:50:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit d1974eae34bce9e275f1a9c3505012513d7aa45e
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Thu Sep 11 16:33:49 2014 +0200
Add peekByte method to Stream, DecodeStream and ChunkedStream
---
src/core/chunked_stream.js | 6 ++++++
src/core/parser.js | 2 +-
src/core/stream.js | 12 +++++++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js
index 7c2aa5b..9578c79 100644
--- a/src/core/chunked_stream.js
+++ b/src/core/chunked_stream.js
@@ -195,6 +195,12 @@ var ChunkedStream = (function ChunkedStreamClosure() {
return bytes.subarray(pos, end);
},
+ peekByte: function ChunkedStream_peekByte() {
+ var peekedByte = this.getByte();
+ this.pos--;
+ return peekedByte;
+ },
+
peekBytes: function ChunkedStream_peekBytes(length) {
var bytes = this.getBytes(length);
this.pos -= bytes.length;
diff --git a/src/core/parser.js b/src/core/parser.js
index 8b83c5d..4af57fb 100644
--- a/src/core/parser.js
+++ b/src/core/parser.js
@@ -478,7 +478,7 @@ var Lexer = (function LexerClosure() {
return (this.currentChar = this.stream.getByte());
},
peekChar: function Lexer_peekChar() {
- return this.stream.peekBytes(1)[0];
+ return this.stream.peekByte();
},
getNumber: function Lexer_getNumber() {
var ch = this.currentChar;
diff --git a/src/core/stream.js b/src/core/stream.js
index 482091e..bd24473 100644
--- a/src/core/stream.js
+++ b/src/core/stream.js
@@ -73,6 +73,11 @@ var Stream = (function StreamClosure() {
this.pos = end;
return bytes.subarray(pos, end);
},
+ peekByte: function Stream_peekByte() {
+ var peekedByte = this.getByte();
+ this.pos--;
+ return peekedByte;
+ },
peekBytes: function Stream_peekBytes(length) {
var bytes = this.getBytes(length);
this.pos -= bytes.length;
@@ -202,6 +207,11 @@ var DecodeStream = (function DecodeStreamClosure() {
this.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) {
var bytes = this.getBytes(length);
this.pos -= bytes.length;
@@ -527,7 +537,7 @@ var FlateStream = (function FlateStreamClosure() {
var end = bufferLength + blockLen;
this.bufferLength = end;
if (blockLen === 0) {
- if (str.peekBytes(1).length === 0) {
+ if (str.peekByte() === -1) {
this.eof = true;
}
} else {
--
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