diff options
author | Jisi Liu <liujisi@google.com> | 2017-07-24 14:59:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 14:59:27 -0700 |
commit | 72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5 (patch) | |
tree | c04e02e5fe58c1db617a6b8eb0bf6e2b69f55d96 /js/binary/writer.js | |
parent | 942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff) | |
parent | dd091aad48423f3a047977e6662f0201194b9bfc (diff) | |
download | protobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.tar.gz protobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.tar.bz2 protobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.zip |
Merge pull request #3393 from pherl/3.4.x
Create 3.4.x branch
Diffstat (limited to 'js/binary/writer.js')
-rw-r--r-- | js/binary/writer.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/js/binary/writer.js b/js/binary/writer.js index 672e94bd..037e92b2 100644 --- a/js/binary/writer.js +++ b/js/binary/writer.js @@ -235,7 +235,7 @@ jspb.BinaryWriter.prototype.getResultBuffer = function() { /** - * Converts the encoded data into a bas64-encoded string. + * Converts the encoded data into a base64-encoded string. * @return {string} */ jspb.BinaryWriter.prototype.getResultBase64String = function() { @@ -716,13 +716,15 @@ jspb.BinaryWriter.prototype.writeDouble = function(field, value) { /** - * Writes a boolean field to the buffer. + * Writes a boolean field to the buffer. 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 {number} field The field number. - * @param {boolean?} value The value to write. + * @param {boolean?|number?} value The value to write. */ jspb.BinaryWriter.prototype.writeBool = function(field, value) { if (value == null) return; - goog.asserts.assert(goog.isBoolean(value)); + goog.asserts.assert(goog.isBoolean(value) || goog.isNumber(value)); this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.VARINT); this.encoder_.writeBool(value); }; |