aboutsummaryrefslogtreecommitdiffhomepage
path: root/js/binary/encoder.js
diff options
context:
space:
mode:
authorGravatar Jisi Liu <liujisi@google.com>2017-07-24 14:59:27 -0700
committerGravatar GitHub <noreply@github.com>2017-07-24 14:59:27 -0700
commit72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5 (patch)
treec04e02e5fe58c1db617a6b8eb0bf6e2b69f55d96 /js/binary/encoder.js
parent942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff)
parentdd091aad48423f3a047977e6662f0201194b9bfc (diff)
Merge pull request #3393 from pherl/3.4.x
Create 3.4.x branch
Diffstat (limited to 'js/binary/encoder.js')
-rw-r--r--js/binary/encoder.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/js/binary/encoder.js b/js/binary/encoder.js
index f25935f1..8e9f5bbc 100644
--- a/js/binary/encoder.js
+++ b/js/binary/encoder.js
@@ -390,11 +390,13 @@ jspb.BinaryEncoder.prototype.writeDouble = function(value) {
/**
- * Writes a boolean value to the buffer as a varint.
- * @param {boolean} value The value to write.
+ * Writes a boolean value to the buffer as a varint. We allow numbers as input
+ * because the JSPB code generator uses 0/1 instead of true/false to save space
+ * in the string representation of the proto.
+ * @param {boolean|number} value The value to write.
*/
jspb.BinaryEncoder.prototype.writeBool = function(value) {
- goog.asserts.assert(goog.isBoolean(value));
+ goog.asserts.assert(goog.isBoolean(value) || goog.isNumber(value));
this.buffer_.push(value ? 1 : 0);
};