Down Integrate Internal Changes
diff --git a/js/binary/decoder.js b/js/binary/decoder.js index e0cd12e..75d4ff7 100644 --- a/js/binary/decoder.js +++ b/js/binary/decoder.js
@@ -180,9 +180,9 @@ jspb.BinaryDecoder.prototype.setBlock = function(data, opt_start, opt_length) { this.bytes_ = jspb.utils.byteSourceToUint8Array(data); - this.start_ = goog.isDef(opt_start) ? opt_start : 0; - this.end_ = - goog.isDef(opt_length) ? this.start_ + opt_length : this.bytes_.length; + this.start_ = (opt_start !== undefined) ? opt_start : 0; + this.end_ = (opt_length !== undefined) ? this.start_ + opt_length : + this.bytes_.length; this.cursor_ = this.start_; };
diff --git a/js/binary/encoder.js b/js/binary/encoder.js index 0387f04..726481b 100644 --- a/js/binary/encoder.js +++ b/js/binary/encoder.js
@@ -414,7 +414,7 @@ * @param {boolean|number} value The value to write. */ jspb.BinaryEncoder.prototype.writeBool = function(value) { - goog.asserts.assert(goog.isBoolean(value) || goog.isNumber(value)); + goog.asserts.assert(typeof value === 'boolean' || typeof value === 'number'); this.buffer_.push(value ? 1 : 0); };
diff --git a/js/binary/proto_test.js b/js/binary/proto_test.js index ae31c8d..aee327a 100644 --- a/js/binary/proto_test.js +++ b/js/binary/proto_test.js
@@ -176,7 +176,7 @@ * @return {boolean} */ function bytesCompare(arr, expected) { - if (goog.isString(arr)) { + if (typeof arr === 'string') { arr = goog.crypt.base64.decodeStringToUint8Array(arr); } if (arr.length != expected.length) { @@ -481,8 +481,8 @@ var msg = new proto.jspb.test.TestAllTypes(); function assertGetters() { - assertTrue(goog.isString(msg.getRepeatedBytesList_asB64()[0])); - assertTrue(goog.isString(msg.getRepeatedBytesList_asB64()[1])); + assertTrue(typeof msg.getRepeatedBytesList_asB64()[0] === 'string'); + assertTrue(typeof msg.getRepeatedBytesList_asB64()[1] === 'string'); assertTrue(msg.getRepeatedBytesList_asU8()[0] instanceof Uint8Array); assertTrue(msg.getRepeatedBytesList_asU8()[1] instanceof Uint8Array);
diff --git a/js/binary/reader.js b/js/binary/reader.js index 9e193ac..2af1a4a 100644 --- a/js/binary/reader.js +++ b/js/binary/reader.js
@@ -445,9 +445,9 @@ * @param {string} callbackName * @param {function(!jspb.BinaryReader):*} callback */ -jspb.BinaryReader.prototype.registerReadCallback = - function(callbackName, callback) { - if (goog.isNull(this.readCallbacks_)) { +jspb.BinaryReader.prototype.registerReadCallback = function( + callbackName, callback) { + if (this.readCallbacks_ === null) { this.readCallbacks_ = {}; } goog.asserts.assert(!this.readCallbacks_[callbackName]); @@ -461,7 +461,7 @@ * @return {*} The value returned by the callback. */ jspb.BinaryReader.prototype.runReadCallback = function(callbackName) { - goog.asserts.assert(!goog.isNull(this.readCallbacks_)); + goog.asserts.assert(this.readCallbacks_ !== null); var callback = this.readCallbacks_[callbackName]; goog.asserts.assert(callback); return callback(this);
diff --git a/js/binary/utils.js b/js/binary/utils.js index c2965c4..195247e 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js
@@ -1001,7 +1001,7 @@ * @return {string} Stringified scalar for text format. */ jspb.utils.debugScalarToTextFormat = function(scalar) { - if (goog.isString(scalar)) { + if (typeof scalar === 'string') { return goog.string.quote(scalar); } else { return scalar.toString();
diff --git a/js/binary/utils_test.js b/js/binary/utils_test.js index 51a9dee..e953ace 100644 --- a/js/binary/utils_test.js +++ b/js/binary/utils_test.js
@@ -356,7 +356,7 @@ */ function test(x, opt_bits) { jspb.utils.splitFloat32(x); - if (goog.isDef(opt_bits)) { + if (opt_bits !== undefined) { if (opt_bits != jspb.utils.split64Low) throw 'fail!'; } expect(truncate(x)) @@ -428,11 +428,11 @@ */ function test(x, opt_highBits, opt_lowBits) { jspb.utils.splitFloat64(x); - if (goog.isDef(opt_highBits)) { + if (opt_highBits !== undefined) { var split64High = jspb.utils.split64High; expect(opt_highBits.toString(16)).toEqual(split64High.toString(16)); } - if (goog.isDef(opt_lowBits)) { + if (opt_lowBits !== undefined) { var split64Low = jspb.utils.split64Low; expect(opt_lowBits.toString(16)).toEqual(split64Low.toString(16)); }
diff --git a/js/binary/writer.js b/js/binary/writer.js index 8c5bff8..ab9a815 100644 --- a/js/binary/writer.js +++ b/js/binary/writer.js
@@ -748,7 +748,7 @@ */ jspb.BinaryWriter.prototype.writeBool = function(field, value) { if (value == null) return; - goog.asserts.assert(goog.isBoolean(value) || goog.isNumber(value)); + goog.asserts.assert(typeof value === 'boolean' || typeof value === 'number'); this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.VARINT); this.encoder_.writeBool(value); };
diff --git a/js/map.js b/js/map.js index 589a293..ab852e4 100644 --- a/js/map.js +++ b/js/map.js
@@ -208,13 +208,13 @@ } }; -if (typeof(Symbol) != 'undefined') { - /** @override */ - jspb.Map.ArrayIteratorIterable_.prototype[Symbol.iterator] = function() { - return this; - }; -} +if (typeof(Symbol) != 'undefined') { +/** @override */ +jspb.Map.ArrayIteratorIterable_.prototype[Symbol.iterator] = function() { + return this; +}; +} /** * Returns the map's length (number of key/value pairs).
diff --git a/js/message.js b/js/message.js index 52c541e..4bf0378 100644 --- a/js/message.js +++ b/js/message.js
@@ -778,7 +778,7 @@ * @return {?string} The field's coerced value. */ jspb.Message.bytesAsB64 = function(value) { - if (value == null || goog.isString(value)) { + if (value == null || typeof value === 'string') { return value; } if (jspb.Message.SUPPORTS_UINT8ARRAY_ && value instanceof Uint8Array) { @@ -800,7 +800,7 @@ if (value == null || value instanceof Uint8Array) { return value; } - if (goog.isString(value)) { + if (typeof value === 'string') { return goog.crypt.base64.decodeStringToUint8Array(value); } goog.asserts.fail('Cannot coerce to Uint8Array: ' + goog.typeOf(value)); @@ -816,7 +816,7 @@ */ jspb.Message.bytesListAsB64 = function(value) { jspb.Message.assertConsistentTypes_(value); - if (!value.length || goog.isString(value[0])) { + if (!value.length || typeof value[0] === 'string') { return /** @type {!Array<string>} */ (value); } return goog.array.map(value, jspb.Message.bytesAsB64); @@ -1654,8 +1654,8 @@ if (!goog.isObject(field1) || !goog.isObject(field2)) { // NaN != NaN so we cover this case. - if ((goog.isNumber(field1) && isNaN(field1)) || - (goog.isNumber(field2) && isNaN(field2))) { + if ((typeof field1 === 'number' && isNaN(field1)) || + (typeof field2 === 'number' && isNaN(field2))) { // One of the fields might be a string 'NaN'. return String(field1) == String(field2); }
diff --git a/js/message_test.js b/js/message_test.js index b2d0da1..e038f65 100644 --- a/js/message_test.js +++ b/js/message_test.js
@@ -855,7 +855,7 @@ var assertNan = function(x) { assertTrue( 'Expected ' + x + ' (' + goog.typeOf(x) + ') to be NaN.', - goog.isNumber(x) && isNaN(x)); + typeof x === 'number' && isNaN(x)); }; var message = new proto.jspb.test.FloatingPointFields([
diff --git a/js/proto3_test.js b/js/proto3_test.js index 7f9d71d..79acc3c 100644 --- a/js/proto3_test.js +++ b/js/proto3_test.js
@@ -54,7 +54,7 @@ * @return {boolean} */ function bytesCompare(arr, expected) { - if (goog.isString(arr)) { + if (typeof arr === 'string') { arr = goog.crypt.base64.decodeStringToUint8Array(arr); } if (arr.length != expected.length) {