aboutsummaryrefslogtreecommitdiffhomepage
path: root/js/binary/decoder.js
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2016-03-30 11:39:59 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2016-03-30 11:39:59 -0700
commit3b3c8abb9635eb3ea078a821a99c9ef29d66dff7 (patch)
tree7d2ec154f15c9f9153d890e76b6cf30e471ea488 /js/binary/decoder.js
parent78105897a8f01c7be9cf8502b6c58d47eb1ccdd7 (diff)
Integrate google internal changes.
Diffstat (limited to 'js/binary/decoder.js')
-rw-r--r--js/binary/decoder.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/js/binary/decoder.js b/js/binary/decoder.js
index 9004eff0..41094a36 100644
--- a/js/binary/decoder.js
+++ b/js/binary/decoder.js
@@ -223,7 +223,7 @@ jspb.BinaryIterator.prototype.next = function() {
jspb.BinaryDecoder = function(opt_bytes, opt_start, opt_length) {
/**
* Typed byte-wise view of the source buffer.
- * @private {Uint8Array}
+ * @private {?Uint8Array}
*/
this.bytes_ = null;
@@ -335,7 +335,7 @@ jspb.BinaryDecoder.prototype.clear = function() {
/**
* Returns the raw buffer.
- * @return {Uint8Array} The raw buffer.
+ * @return {?Uint8Array} The raw buffer.
*/
jspb.BinaryDecoder.prototype.getBuffer = function() {
return this.bytes_;
@@ -631,6 +631,7 @@ jspb.BinaryDecoder.prototype.readUnsignedVarint32String = function() {
return value.toString();
};
+
/**
* Reads a 32-bit signed variant and returns its value as a string.
*
@@ -950,14 +951,15 @@ jspb.BinaryDecoder.prototype.readStringWithLength = function() {
* Reads a block of raw bytes from the binary stream.
*
* @param {number} length The number of bytes to read.
- * @return {Uint8Array} The decoded block of bytes, or null if the length was
- * invalid.
+ * @return {!Uint8Array} The decoded block of bytes, or an empty block if the
+ * length was invalid.
*/
jspb.BinaryDecoder.prototype.readBytes = function(length) {
if (length < 0 ||
this.cursor_ + length > this.bytes_.length) {
this.error_ = true;
- return null;
+ goog.asserts.fail('Invalid byte length!');
+ return new Uint8Array(0);
}
var result = this.bytes_.subarray(this.cursor_, this.cursor_ + length);